Skip to content

Commit

Permalink
Buttons sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
topilski committed Dec 16, 2018
1 parent 53c81fd commit 63e2504
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/gui/db/redis/shell_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void ShellWidget::init() {

QHBoxLayout* ShellWidget::createTopLayout(core::ConnectionType ct) {
QHBoxLayout* top_layout = base_class::createTopLayout(ct);
modules_ = new common::qt::gui::IconComboBox(gui::GuiFactory::GetInstance().moduleIcon(), shell_icon_size);
modules_ = new common::qt::gui::IconComboBox(gui::GuiFactory::GetInstance().moduleIcon(), kShellIconSize);
top_layout->addWidget(modules_);
return top_layout;
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class MainWindow : public QMainWindow {

public:
enum {
min_width = 800,
min_height = 600,
preferred_width = 1024,
preferred_height = 768,
min_width = 1024,
min_height = 768,
preferred_width = 1280,
preferred_height = 800,
max_recent_connections = 10
};

Expand Down
112 changes: 61 additions & 51 deletions src/gui/shell/base_shell_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
#include <string>
#include <vector>

#include <QAction>
#include <QCheckBox>
#include <QComboBox>
#include <QFileDialog>
#include <QLabel>
#include <QMessageBox>
#include <QProgressBar>
#include <QPushButton>
#include <QSpinBox>
#include <QSplitter>
#include <QToolBar>
Expand Down Expand Up @@ -69,8 +69,8 @@ const QString trBasedOn_2S = QObject::tr("Based on <b>%1</b> version: <b>%2</b>"
namespace fastonosql {
namespace gui {

const QSize BaseShellWidget::top_bar_icon_size = QSize(24, 24);
const QSize BaseShellWidget::shell_icon_size = QSize(32, 32);
const QSize BaseShellWidget::kIconSize = QSize(24, 24);
const QSize BaseShellWidget::kShellIconSize = QSize(32, 32);

BaseShellWidget* BaseShellWidget::createWidget(proxy::IServerSPtr server, const QString& filePath, QWidget* parent) {
#if defined(BUILD_WITH_REDIS) && defined(PRO_VERSION)
Expand Down Expand Up @@ -113,44 +113,51 @@ BaseShellWidget::BaseShellWidget(proxy::IServerSPtr server, const QString& fileP
history_call_(nullptr),
file_path_(filePath) {}

QToolBar* BaseShellWidget::createToolBar() {
QToolBar* savebar = new QToolBar;
load_action_ = new QAction(this);
QHBoxLayout* BaseShellWidget::createActionBar() {
QHBoxLayout* savebar = new QHBoxLayout;
load_action_ = new QPushButton;
load_action_->setFixedSize(kIconSize);
load_action_->setIcon(gui::GuiFactory::GetInstance().loadIcon());
typedef void (BaseShellWidget::*lf)();
VERIFY(connect(load_action_, &QAction::triggered, this, static_cast<lf>(&BaseShellWidget::loadFromFile)));
savebar->addAction(load_action_);
VERIFY(connect(load_action_, &QPushButton::clicked, this, static_cast<lf>(&BaseShellWidget::loadFromFile)));
savebar->addWidget(load_action_);

save_action_ = new QAction(this);
save_action_ = new QPushButton;
save_action_->setFixedSize(kIconSize);
save_action_->setIcon(gui::GuiFactory::GetInstance().saveIcon());
VERIFY(connect(save_action_, &QAction::triggered, this, &BaseShellWidget::saveToFile));
savebar->addAction(save_action_);
VERIFY(connect(save_action_, &QPushButton::clicked, this, &BaseShellWidget::saveToFile));
savebar->addWidget(save_action_);

save_as_action_ = new QAction(this);
save_as_action_ = new QPushButton;
save_as_action_->setFixedSize(kIconSize);
save_as_action_->setIcon(gui::GuiFactory::GetInstance().saveAsIcon());
VERIFY(connect(save_as_action_, &QAction::triggered, this, &BaseShellWidget::saveToFileAs));
savebar->addAction(save_as_action_);
VERIFY(connect(save_as_action_, &QPushButton::clicked, this, &BaseShellWidget::saveToFileAs));
savebar->addWidget(save_as_action_);

connect_action_ = new QAction(this);
connect_action_ = new QPushButton;
connect_action_->setFixedSize(kIconSize);
connect_action_->setIcon(gui::GuiFactory::GetInstance().connectIcon());
VERIFY(connect(connect_action_, &QAction::triggered, this, &BaseShellWidget::connectToServer));
savebar->addAction(connect_action_);
VERIFY(connect(connect_action_, &QPushButton::clicked, this, &BaseShellWidget::connectToServer));
savebar->addWidget(connect_action_);

disconnect_action_ = new QAction(this);
disconnect_action_ = new QPushButton;
disconnect_action_->setFixedSize(kIconSize);
disconnect_action_->setIcon(gui::GuiFactory::GetInstance().disConnectIcon());
VERIFY(connect(disconnect_action_, &QAction::triggered, this, &BaseShellWidget::disconnectFromServer));
savebar->addAction(disconnect_action_);
VERIFY(connect(disconnect_action_, &QPushButton::clicked, this, &BaseShellWidget::disconnectFromServer));
savebar->addWidget(disconnect_action_);

execute_action_ = new QAction(this);
execute_action_ = new QPushButton;
execute_action_->setFixedSize(kIconSize);
execute_action_->setIcon(gui::GuiFactory::GetInstance().executeIcon());
execute_action_->setShortcut(gui::g_execute_key);
VERIFY(connect(execute_action_, &QAction::triggered, this, &BaseShellWidget::execute));
savebar->addAction(execute_action_);
VERIFY(connect(execute_action_, &QPushButton::clicked, this, &BaseShellWidget::execute));
savebar->addWidget(execute_action_);

stop_action_ = new QAction(this);
stop_action_ = new QPushButton;
stop_action_->setFixedSize(kIconSize);
stop_action_->setIcon(gui::GuiFactory::GetInstance().stopIcon());
VERIFY(connect(stop_action_, &QAction::triggered, this, &BaseShellWidget::stop));
savebar->addAction(stop_action_);
VERIFY(connect(stop_action_, &QPushButton::clicked, this, &BaseShellWidget::stop));
savebar->addWidget(stop_action_);
return savebar;
}

Expand Down Expand Up @@ -185,17 +192,15 @@ void BaseShellWidget::init() {
QVBoxLayout* main_layout = new QVBoxLayout;
QHBoxLayout* hlayout = new QHBoxLayout;

QToolBar* savebar = createToolBar();
savebar->setMovable(false);

QHBoxLayout* savebar = createActionBar();
static const core::ConnectionMode mode = core::InteractiveMode;
const std::string mode_str = common::ConvertToString(mode);
QString qmode_str;
common::ConvertFromString(mode_str, &qmode_str);
connection_mode_ =
new common::qt::gui::IconLabel(gui::GuiFactory::GetInstance().modeIcon(mode), top_bar_icon_size, qmode_str);
new common::qt::gui::IconLabel(gui::GuiFactory::GetInstance().modeIcon(mode), kIconSize, qmode_str);

hlayout->addWidget(savebar);
hlayout->addLayout(savebar);
QSplitter* savebar_splitter = new QSplitter(Qt::Horizontal);
hlayout->addWidget(savebar_splitter);

Expand All @@ -204,16 +209,19 @@ void BaseShellWidget::init() {
work_progressbar_->setTextVisible(true);
hlayout->addWidget(work_progressbar_);

QToolBar* helpbar = new QToolBar;
helpbar->setMovable(false);
validate_action_ = new QAction(gui::GuiFactory::GetInstance().failIcon(), translations::trValidate, helpbar);
VERIFY(connect(validate_action_, &QAction::triggered, this, &BaseShellWidget::validateClick));
helpbar->addAction(validate_action_);

QAction* help_action = new QAction(gui::GuiFactory::GetInstance().helpIcon(), translations::trHelp, helpbar);
VERIFY(connect(help_action, &QAction::triggered, this, &BaseShellWidget::helpClick));
helpbar->addAction(help_action);
hlayout->addWidget(helpbar);
QHBoxLayout* helpbar = new QHBoxLayout;
validate_action_ = new QPushButton;
validate_action_->setFixedSize(kIconSize);
validate_action_->setIcon(gui::GuiFactory::GetInstance().failIcon());
VERIFY(connect(validate_action_, &QPushButton::clicked, this, &BaseShellWidget::validateClick));
helpbar->addWidget(validate_action_);

help_action_ = new QPushButton;
help_action_->setFixedSize(kIconSize);
help_action_->setIcon(gui::GuiFactory::GetInstance().helpIcon());
VERIFY(connect(help_action_, &QPushButton::clicked, this, &BaseShellWidget::helpClick));
helpbar->addWidget(help_action_);
hlayout->addLayout(helpbar);
main_layout->addLayout(hlayout, 0);

advanced_options_ = new QCheckBox;
Expand Down Expand Up @@ -306,11 +314,11 @@ void BaseShellWidget::init() {

QHBoxLayout* BaseShellWidget::createTopLayout(core::ConnectionType ct) {
QHBoxLayout* top_layout = new QHBoxLayout;
server_name_ = new common::qt::gui::IconLabel(gui::GuiFactory::GetInstance().icon(ct), shell_icon_size,
server_name_ = new common::qt::gui::IconLabel(gui::GuiFactory::GetInstance().icon(ct), kShellIconSize,
translations::trCalculate + "...");
server_name_->setElideMode(Qt::ElideRight);
top_layout->addWidget(server_name_);
db_name_ = new common::qt::gui::IconLabel(gui::GuiFactory::GetInstance().databaseIcon(), shell_icon_size,
db_name_ = new common::qt::gui::IconLabel(gui::GuiFactory::GetInstance().databaseIcon(), kShellIconSize,
translations::trCalculate + "...");
top_layout->addWidget(db_name_);
QSplitter* padding = new QSplitter(Qt::Horizontal);
Expand Down Expand Up @@ -347,13 +355,15 @@ void BaseShellWidget::changeEvent(QEvent* ev) {
}

void BaseShellWidget::retranslateUi() {
load_action_->setText(translations::trLoad);
save_action_->setText(translations::trSave);
save_as_action_->setText(translations::trSaveAs);
connect_action_->setText(translations::trConnect);
disconnect_action_->setText(translations::trDisconnect);
execute_action_->setText(translations::trExecute);
stop_action_->setText(translations::trStop);
validate_action_->setToolTip(translations::trValidate);
help_action_->setToolTip(translations::trHelp);
load_action_->setToolTip(translations::trLoad);
save_action_->setToolTip(translations::trSave);
save_as_action_->setToolTip(translations::trSaveAs);
connect_action_->setToolTip(translations::trConnect);
disconnect_action_->setToolTip(translations::trDisconnect);
execute_action_->setToolTip(translations::trExecute);
stop_action_->setToolTip(translations::trStop);

history_call_->setText(translations::trHistory);
setToolTip(trBasedOn_2S.arg(input_->basedOn(), input_->version()));
Expand Down Expand Up @@ -534,7 +544,7 @@ void BaseShellWidget::progressChange(const proxy::events_info::ProgressInfoRespo

void BaseShellWidget::enterMode(const proxy::events_info::EnterModeInfo& res) {
core::ConnectionMode mode = res.mode;
connection_mode_->setIcon(gui::GuiFactory::GetInstance().modeIcon(mode), top_bar_icon_size);
connection_mode_->setIcon(gui::GuiFactory::GetInstance().modeIcon(mode), kIconSize);
std::string modeText = common::ConvertToString(mode);
QString qmodeText;
common::ConvertFromString(modeText, &qmodeText);
Expand Down
25 changes: 13 additions & 12 deletions src/gui/shell/base_shell_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "proxy/proxy_fwd.h" // for IServerSPtr

class QAction; // lines 26-26
class QPushButton; // lines 26-26
class QComboBox; // lines 29-29
class QProgressBar; // lines 27-27
class QCheckBox;
Expand Down Expand Up @@ -76,8 +76,8 @@ class BaseShellWidget : public QWidget {
Q_OBJECT

public:
static const QSize top_bar_icon_size;
static const QSize shell_icon_size;
static const QSize kIconSize;
static const QSize kShellIconSize;

static BaseShellWidget* createWidget(proxy::IServerSPtr server,
const QString& filePath = QString(),
Expand Down Expand Up @@ -148,7 +148,7 @@ class BaseShellWidget : public QWidget {
void changeEvent(QEvent* ev) override;

private:
QToolBar* createToolBar();
QHBoxLayout* createActionBar();

void retranslateUi();

Expand All @@ -163,14 +163,15 @@ class BaseShellWidget : public QWidget {
void updateDBLabel(const QString& text);

const proxy::IServerSPtr server_;
QAction* execute_action_;
QAction* stop_action_;
QAction* connect_action_;
QAction* disconnect_action_;
QAction* load_action_;
QAction* save_action_;
QAction* save_as_action_;
QAction* validate_action_;
QPushButton* execute_action_;
QPushButton* stop_action_;
QPushButton* connect_action_;
QPushButton* disconnect_action_;
QPushButton* load_action_;
QPushButton* save_action_;
QPushButton* save_as_action_;
QPushButton* validate_action_;
QPushButton* help_action_;
QLabel* supported_commands_count_;
QLabel* validated_commands_count_;
QComboBox* commands_version_api_;
Expand Down
8 changes: 6 additions & 2 deletions src/gui/widgets/output_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ FastoCommonItem* CreateRootItem(core::FastoObject* item) {

} // namespace

const QSize OutputWidget::icon_size = QSize(24, 24);
const QSize OutputWidget::kIconSize = QSize(24, 24);

OutputWidget::OutputWidget(proxy::IServerSPtr server, QWidget* parent) : base_class(parent), server_(server) {
CHECK(server_);
Expand Down Expand Up @@ -115,10 +115,14 @@ OutputWidget::OutputWidget(proxy::IServerSPtr server, QWidget* parent) : base_cl

QHBoxLayout* top_layout = new QHBoxLayout;
tree_button_ = new QPushButton;
tree_button_->setFixedSize(kIconSize);
table_button_ = new QPushButton;
table_button_->setFixedSize(kIconSize);
text_button_ = new QPushButton;
text_button_->setFixedSize(kIconSize);
key_button_ = new QPushButton;
time_label_ = new common::qt::gui::IconLabel(GuiFactory::GetInstance().timeIcon(), icon_size, "0");
key_button_->setFixedSize(kIconSize);
time_label_ = new common::qt::gui::IconLabel(GuiFactory::GetInstance().timeIcon(), kIconSize, "0");
tree_button_->setIcon(GuiFactory::GetInstance().treeIcon());
VERIFY(connect(tree_button_, &QPushButton::clicked, this, &OutputWidget::setTreeView));
table_button_->setIcon(GuiFactory::GetInstance().tableIcon());
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/output_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class OutputWidget : public QWidget {
Q_OBJECT
public:
typedef QWidget base_class;
static const QSize icon_size;
static const QSize kIconSize;

explicit OutputWidget(proxy::IServerSPtr server, QWidget* parent = Q_NULLPTR);

Expand Down

0 comments on commit 63e2504

Please sign in to comment.