Skip to content

Commit

Permalink
empty ws list bug was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nvpopov committed Jul 10, 2021
1 parent 4682666 commit e1d5c50
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 369 deletions.
8 changes: 4 additions & 4 deletions data/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
}

QScrollBar::add-line:horizontal {
border: none;
background: none;
border: none;
background: none;
}

QScrollBar::sub-line:horizontal {
Expand Down Expand Up @@ -218,7 +218,7 @@ QListWidget {
}

QListWidget::item {
margin: 5px;
margin: 5px;
}

QSplitter {
Expand Down Expand Up @@ -450,7 +450,7 @@ QComboBox:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled {
}

QComboBox {
padding: 3px 6px 3px 6px;
padding: 1px 6px 1px 6px;
}

QPushButton, QComboBox, QSpinBox, QDoubleSpinBox, QToolButton{
Expand Down
2 changes: 1 addition & 1 deletion src/qppcad/core/gizmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void gizmo_t::render () {
&& (is_edit_item || (!is_edit_item && attached_item->get_num_cnt_selected() > 0))) {
astate->dp->render_cube(m_pos, v_scale * 1.2f, clr_gray);
std::array<vector3<float>, 3> tmp_pos_hat {
m_pos + gizmo_axis[0] * m_shift_magn,
m_pos + gizmo_axis[0] * m_shift_magn,
m_pos + gizmo_axis[1] * m_shift_magn,
m_pos + gizmo_axis[2] * m_shift_magn
};
Expand Down
27 changes: 14 additions & 13 deletions src/qppcad/core/workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,25 @@ class workspace_manager_t : public std::enable_shared_from_this<workspace_manage
auto cur_it = cur_ws->get_sel_sp();
if (!cur_it) {
if (error_context & error_ctx_throw)
throw std::invalid_argument("No item selected in the workspace");
throw std::invalid_argument("No item in the workspace is selected");
if (error_context & error_ctx_mbox)
QMessageBox::warning(nullptr,
QObject::tr("Error"),
QObject::tr("No item selected in the workspace"));
QObject::tr("No item in the workspace is selected"));
return {cur_ws, nullptr, nullptr};
}

auto casted_it = cur_it->cast_as<T>();
if (!casted_it) {
if (error_context & error_ctx_throw)
throw std::invalid_argument(
fmt::format("Cannot cast types: from {} to {}",
fmt::format("Cannot perform typecast: from {} to {}",
cur_it->get_type_name(), T::get_type_name_static())
);
if (error_context & error_ctx_mbox)
QMessageBox::warning(nullptr,
QObject::tr("Error"),
QObject::tr("Cannot cast types: from %1 to %2")
QObject::tr("Cannot perform typecast: from %1 to %2")
.arg(QString::fromStdString(cur_it->get_type_name()))
.arg(QString::fromStdString(T::get_type_name_static()))
);
Expand Down Expand Up @@ -244,23 +244,23 @@ class workspace_manager_t : public std::enable_shared_from_this<workspace_manage
auto cur_it = cur_ws->get_sel_sp();
if (!cur_it) {
if (error_context & error_ctx_throw)
throw std::invalid_argument("No item selected in the workspace");
throw std::invalid_argument("No item in the workspace is selected");
if (error_context & error_ctx_mbox)
QMessageBox::warning(nullptr, QObject::tr("Error"),
QObject::tr("No item selected in the workspace"));
QObject::tr("No item in the workspace is selected"));
return {cur_ws, nullptr, nullptr, false};
}

auto casted_it = cur_it->cast_as<T>();
if (!casted_it) {
if (error_context & error_ctx_throw)
throw std::invalid_argument(
fmt::format("Cannot cast types: from {} to {}",
fmt::format("Cannot perform typecast: from {} to {}",
cur_it->get_type_name(), T::get_type_name_static()));
if (error_context & error_ctx_mbox)
QMessageBox::warning(nullptr,
QObject::tr("Error"),
QObject::tr("Cannot cast types: from %1 to %2")
QObject::tr("Cannot perform typecast: from %1 to %2")
.arg(QString::fromStdString(cur_it->get_type_name()))
.arg(QString::fromStdString(T::get_type_name_static()))
);
Expand Down Expand Up @@ -291,11 +291,11 @@ class workspace_manager_t : public std::enable_shared_from_this<workspace_manage
auto cur_it = cur_ws->get_sel_sp();
if (!cur_it) {
if (error_context & error_ctx_throw)
throw std::invalid_argument("No item selected in the workspace");
throw std::invalid_argument("No item in the workspace is selected");
if (error_context & error_ctx_mbox)
QMessageBox::warning(nullptr,
QObject::tr("Error"),
QObject::tr("No item selected in the workspace"));
QObject::tr("No item in the workspace is selected"));
return {cur_ws, nullptr, false};
}

Expand All @@ -311,11 +311,12 @@ class workspace_manager_t : public std::enable_shared_from_this<workspace_manage
get_sel_tuple_ws(uint32_t error_context = error_ctx_def) {
if (!has_wss()) {
if (error_context & error_ctx_throw)
throw std::invalid_argument("There are`t workspaces in the field");
if (error_context & error_ctx_mbox)
throw std::invalid_argument("The list of open workspaces is empty");
if (error_context & error_ctx_mbox) {
QMessageBox::warning(nullptr,
QObject::tr("Error"),
QObject::tr("There are`t workspaces in the field"));
QObject::tr("The list of open workspaces is empty"));
}
return {false, nullptr};
}

Expand Down
12 changes: 4 additions & 8 deletions src/qppcad/ui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ void main_window_t::request_undo_redo_buttons_update() {
if (!m_edit_menu_undo || !m_edit_menu_redo)
return;
app_state_t* astate = app_state_t::get_inst();
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws(error_ctx_mbox);
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws(error_ctx_ignore);
if (ok && DEV_ENABLE_HSDOC) {
auto cur_ws_sp = cur_ws.get();
if (cur_ws_sp) {
Expand Down Expand Up @@ -994,7 +994,6 @@ void main_window_t::open_ws() {
}

void main_window_t::save_ws() {

app_state_t* astate = app_state_t::get_inst();

stop_update_cycle();
Expand All @@ -1021,7 +1020,6 @@ void main_window_t::save_ws() {

start_update_cycle();
cur_ws_changed();

}

void main_window_t::save_ws_as() {
Expand Down Expand Up @@ -1352,7 +1350,7 @@ void main_window_t::tp_angle_button_clicked(bool checked) {

void main_window_t::ws_edit_mode_selector_button_clicked(int id) {
app_state_t* astate = app_state_t::get_inst();
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws(error_ctx_mbox);
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws(error_ctx_ignore);
if (ok) {
if (id == 0)
cur_ws->set_edit_type(ws_edit_type_e::edit_item);
Expand Down Expand Up @@ -1451,7 +1449,7 @@ void main_window_t::tp_add_point_sym_group_clicked() {

void main_window_t::tp_scenic_rotation_toggle() {
app_state_t* astate = app_state_t::get_inst();
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws();
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws(error_ctx_ignore);
cur_ws->m_scenic_rotation = !cur_ws->m_scenic_rotation;
}

Expand All @@ -1461,7 +1459,7 @@ void main_window_t::apply_camera_view_change(cam_tv_e target_view) {

void main_window_t::toggle_ws_edit_mode() {
app_state_t* astate = app_state_t::get_inst();
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws();
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws(error_ctx_ignore);
if (ok) {
cur_ws->toggle_edit_mode();
cur_ws_changed();
Expand Down Expand Up @@ -2050,7 +2048,6 @@ void main_window_t::control_bhv_menus_activity() {
}

void main_window_t::make_screenshot() {

app_state_t* astate = app_state_t::get_inst();
auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws(error_ctx_mbox);

Expand All @@ -2065,7 +2062,6 @@ void main_window_t::make_screenshot() {

astate->m_ignore_scanline = false;
astate->make_viewport_dirty();

}

void main_window_t::slot_shortcut_terminate_app() {
Expand Down
5 changes: 0 additions & 5 deletions src/qppcad/ui/object_inspector_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,15 @@ void object_inspector_widget_t::update_ws_items_view_widget() {
}

void object_inspector_widget_t::cur_ws_changed() {

app_state_t* astate = app_state_t::get_inst();

astate->tlog("[DEBUG] object_inspector_widget_t::cur_ws_changed");

m_ws_items_list->blockSignals(true);

m_ws_items_list->clear();
m_ws_items_list->clearSelection();

auto [ok, cur_ws] = astate->ws_mgr->get_sel_tuple_ws(error_ctx_ignore);

if (cur_ws)
for (size_t i = 0; i < cur_ws->num_items(); i++) {
auto ws_item = cur_ws->m_ws_items.get_hs_child_as_array(i);
Expand All @@ -218,7 +215,6 @@ void object_inspector_widget_t::cur_ws_changed() {

cur_ws_selected_item_changed();
m_ws_items_list->blockSignals(false);

}

void object_inspector_widget_t::cur_ws_selected_item_changed() {
Expand Down Expand Up @@ -254,7 +250,6 @@ void object_inspector_widget_t::cur_ws_selected_item_changed() {
}

void object_inspector_widget_t::ui_cur_ws_selected_item_changed() {

app_state_t* astate = app_state_t::get_inst();

astate->tlog("[DEBUG] ui_cur_ws_selected_item_changed");
Expand Down
Loading

0 comments on commit e1d5c50

Please sign in to comment.