Merge branch 'master' of https://gitlab.com/sshumakov3/noggit-red.git
@@ -213,6 +213,7 @@ include_directories(PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# And do the job.
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src" )
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/noggit/ui/style/framelesswindow" )
|
||||
COLLECT_FILES(false noggit_root_sources src/noggit .cpp)
|
||||
COLLECT_FILES(true noggit_ui_sources src/noggit/ui .cpp)
|
||||
COLLECT_FILES(false math_sources src/math .cpp)
|
||||
|
||||
BIN
media/noggit.ico
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
1
media/res.rc
Normal file
@@ -0,0 +1 @@
|
||||
IDI_APP ICON "noggit.ico"
|
||||
BIN
media/splash.png
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 52 KiB |
28
resources/darkstyle.qrc
Normal file
@@ -0,0 +1,28 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>../src/noggit/ui/style/darkstyle/darkstyle.qss</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_close.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_restore.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_undock.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_branch_closed.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_branch_end.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_branch_more.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_branch_open.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_vline.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_checked.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_indeterminate.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_unchecked.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_checked_pressed.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_indeterminate_pressed.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_unchecked_pressed.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_checked_disabled.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_indeterminate_disabled.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_checkbox_unchecked_disabled.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_radiobutton_checked.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_radiobutton_unchecked.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_radiobutton_checked_pressed.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_radiobutton_unchecked_pressed.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_radiobutton_checked_disabled.png</file>
|
||||
<file>../src/noggit/ui/style/darkstyle/icon_radiobutton_unchecked_disabled.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
8
resources/framelesswindow.qrc
Normal file
@@ -0,0 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>../src/noggit/ui/style/images/icon_window_minimize.png</file>
|
||||
<file>../src/noggit/ui/style/images/icon_window_restore.png</file>
|
||||
<file>../src/noggit/ui/style/images/icon_window_maximize.png</file>
|
||||
<file>../src/noggit/ui/style/images/icon_window_close.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1677,6 +1677,7 @@ void MapView::paintGL()
|
||||
if (saving_minimap)
|
||||
{
|
||||
saveMinimap(minimapTool->getMinimapRenderSettings());
|
||||
_main_window->setEnabled(false);
|
||||
}
|
||||
|
||||
const qreal now(_startup_time.elapsed() / 1000.0);
|
||||
@@ -1686,6 +1687,7 @@ void MapView::paintGL()
|
||||
if (!saving_minimap)
|
||||
{
|
||||
tick (now - _last_update);
|
||||
_main_window->setEnabled(true);
|
||||
}
|
||||
|
||||
_last_update = now;
|
||||
@@ -1694,6 +1696,11 @@ void MapView::paintGL()
|
||||
|
||||
draw_map();
|
||||
|
||||
if (saving_minimap)
|
||||
{
|
||||
gl.clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (_world->uid_duplicates_found() && !_uid_duplicate_warning_shown)
|
||||
{
|
||||
_uid_duplicate_warning_shown = true;
|
||||
@@ -2373,7 +2380,7 @@ selection_result MapView::intersect_result(bool terrain_only)
|
||||
( model_view().transposed()
|
||||
, intersect_ray()
|
||||
, terrain_only
|
||||
, terrainMode == editing_mode::object
|
||||
, terrainMode == editing_mode::object || terrainMode == editing_mode::minimap
|
||||
, _draw_terrain.get()
|
||||
, _draw_wmo.get()
|
||||
, _draw_models.get()
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QTCore/QDir>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -1830,9 +1831,15 @@ void World::drawMinimap ( MapTile *tile
|
||||
);
|
||||
}
|
||||
|
||||
// Also load a tile above the current one to correct the lookat approximation
|
||||
tile_index m_tile = tile_index (camera_pos);
|
||||
m_tile.z -= 1;
|
||||
|
||||
bool unload = !mapIndex.has_unsaved_changes(m_tile);
|
||||
MapTile* mTile = mapIndex.loadTile(m_tile);
|
||||
|
||||
int daytime = static_cast<int>(time) % 2880;
|
||||
|
||||
skies->update_sky_colors(camera_pos, daytime);
|
||||
outdoorLightStats = ol->getLightStats(daytime);
|
||||
|
||||
math::vector_3d light_dir = outdoorLightStats.dayDir;
|
||||
@@ -1840,9 +1847,6 @@ void World::drawMinimap ( MapTile *tile
|
||||
// todo: figure out why I need to use a different light vector for the terrain
|
||||
math::vector_3d terrain_light_dir = {-light_dir.z, light_dir.y, -light_dir.x};
|
||||
|
||||
math::vector_3d diffuse_color(skies->color_set[LIGHT_GLOBAL_DIFFUSE] * outdoorLightStats.dayIntensity);
|
||||
math::vector_3d ambient_color(skies->color_set[LIGHT_GLOBAL_AMBIENT] * outdoorLightStats.ambientIntensity);
|
||||
|
||||
culldistance = 100000.0f;
|
||||
|
||||
gl.enable(GL_DEPTH_TEST);
|
||||
@@ -1861,8 +1865,8 @@ void World::drawMinimap ( MapTile *tile
|
||||
mcnk_shader.uniform("draw_terrain_height_contour", static_cast<int>(settings->draw_elevation));
|
||||
|
||||
mcnk_shader.uniform("light_dir", terrain_light_dir);
|
||||
mcnk_shader.uniform("diffuse_color", diffuse_color);
|
||||
mcnk_shader.uniform("ambient_color", ambient_color);
|
||||
mcnk_shader.uniform("diffuse_color", settings->diffuse_color);
|
||||
mcnk_shader.uniform("ambient_color", settings->ambient_color);
|
||||
|
||||
mcnk_shader.uniform("alphamap", 0);
|
||||
mcnk_shader.uniform("tex0", 1);
|
||||
@@ -1885,12 +1889,6 @@ void World::drawMinimap ( MapTile *tile
|
||||
display_mode::in_2D
|
||||
);
|
||||
|
||||
tile_index m_tile = tile_index (camera_pos);
|
||||
m_tile.z -= 1;
|
||||
|
||||
bool unload = !mapIndex.has_unsaved_changes(m_tile);
|
||||
MapTile* mTile = mapIndex.loadTile(m_tile);
|
||||
|
||||
if (mTile)
|
||||
{
|
||||
mTile->wait_until_loaded();
|
||||
@@ -1901,17 +1899,12 @@ void World::drawMinimap ( MapTile *tile
|
||||
);
|
||||
}
|
||||
|
||||
if (unload)
|
||||
{
|
||||
mapIndex.unloadTile(m_tile);
|
||||
}
|
||||
|
||||
gl.bindVertexArray(0);
|
||||
gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
// M2s / models
|
||||
if (settings->draw_m2)
|
||||
if (settings->draw_m2 || settings->use_filters)
|
||||
{
|
||||
|
||||
if (need_model_updates)
|
||||
@@ -1931,15 +1924,59 @@ void World::drawMinimap ( MapTile *tile
|
||||
m2_shader.uniform("tex2", 1);
|
||||
|
||||
m2_shader.uniform("light_dir", light_dir);
|
||||
m2_shader.uniform("diffuse_color", diffuse_color);
|
||||
m2_shader.uniform("ambient_color", ambient_color);
|
||||
m2_shader.uniform("diffuse_color", settings->diffuse_color);
|
||||
m2_shader.uniform("ambient_color", settings->ambient_color);
|
||||
|
||||
for (auto &it : _models_by_filename)
|
||||
{
|
||||
std::vector<ModelInstance*> instances;
|
||||
|
||||
if (settings->use_filters)
|
||||
{
|
||||
instances = it.second;
|
||||
for (auto instance : it.second)
|
||||
{
|
||||
bool found_model = false;
|
||||
bool found_instance = false;
|
||||
|
||||
for (int i = 0; i < settings->m2_model_filter_include->count(); ++i)
|
||||
{
|
||||
auto item_wgt_m = reinterpret_cast<noggit::ui::MinimapM2ModelFilterEntry *>(
|
||||
settings->m2_model_filter_include->itemWidget(settings->m2_model_filter_include->item(i)));
|
||||
|
||||
if (item_wgt_m->getFileName().toStdString() == instance->model->filename
|
||||
&& item_wgt_m->getSizeCategory() <= instance->size_cat)
|
||||
{
|
||||
found_model = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < settings->m2_instance_filter_include->count(); ++i)
|
||||
{
|
||||
auto item_wgt_i = reinterpret_cast<noggit::ui::MinimapInstanceFilterEntry*>(
|
||||
settings->m2_instance_filter_include->itemWidget(settings->m2_instance_filter_include->item(i)));
|
||||
|
||||
if (item_wgt_i->getUid() == instance->uid)
|
||||
{
|
||||
found_instance = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(found_model || found_instance))
|
||||
{
|
||||
std::vector<ModelInstance*>::iterator position = std::find(instances.begin(), instances.end(), instance);
|
||||
if (position != instances.end())
|
||||
{
|
||||
instances.erase(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it.second[0]->model->wait_until_loaded();
|
||||
it.second[0]->model->draw(model_view, it.second, m2_shader, frustum, culldistance, camera_pos, false,
|
||||
animtime, false, false, model_with_particles,
|
||||
model_boxes_to_draw, display_mode::in_2D
|
||||
it.second[0]->model->draw(model_view, settings->use_filters ? instances : it.second, m2_shader, frustum,
|
||||
culldistance, camera_pos, false,animtime, false,
|
||||
false, model_with_particles,model_boxes_to_draw, display_mode::in_2D
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1955,15 +1992,10 @@ void World::drawMinimap ( MapTile *tile
|
||||
water_shader.uniform("model_view", model_view);
|
||||
water_shader.uniform("projection", projection);
|
||||
|
||||
math::vector_4d ocean_color_light(skies->color_set[OCEAN_COLOR_LIGHT], skies->ocean_shallow_alpha());
|
||||
math::vector_4d ocean_color_dark(skies->color_set[OCEAN_COLOR_DARK], skies->ocean_deep_alpha());
|
||||
math::vector_4d river_color_light(skies->color_set[RIVER_COLOR_LIGHT], skies->river_shallow_alpha());
|
||||
math::vector_4d river_color_dark(skies->color_set[RIVER_COLOR_DARK], skies->river_deep_alpha());
|
||||
|
||||
water_shader.uniform("ocean_color_light", ocean_color_light);
|
||||
water_shader.uniform("ocean_color_dark", ocean_color_dark);
|
||||
water_shader.uniform("river_color_light", river_color_light);
|
||||
water_shader.uniform("river_color_dark", river_color_dark);
|
||||
water_shader.uniform("ocean_color_light", settings->ocean_color_light);
|
||||
water_shader.uniform("ocean_color_dark", settings->ocean_color_dark);
|
||||
water_shader.uniform("river_color_light", settings->river_color_light);
|
||||
water_shader.uniform("river_color_dark", settings->river_color_dark);
|
||||
water_shader.uniform("use_transform", 1);
|
||||
|
||||
}
|
||||
@@ -1981,19 +2013,55 @@ void World::drawMinimap ( MapTile *tile
|
||||
wmo_program.uniform("draw_fog", 0);
|
||||
|
||||
wmo_program.uniform("exterior_light_dir", light_dir);
|
||||
wmo_program.uniform("exterior_diffuse_color", diffuse_color);
|
||||
wmo_program.uniform("exterior_ambient_color", ambient_color);
|
||||
wmo_program.uniform("exterior_diffuse_color", settings->diffuse_color);
|
||||
wmo_program.uniform("exterior_ambient_color", settings->ambient_color);
|
||||
|
||||
_model_instance_storage.for_each_wmo_instance([&](WMOInstance &wmo)
|
||||
{
|
||||
wmo.wmo->wait_until_loaded();
|
||||
wmo.draw(wmo_program, model_view, projection, frustum,
|
||||
culldistance, camera_pos, false, false,
|
||||
false, _liquid_render.get(), current_selection(),
|
||||
animtime, skies->hasSkies(), display_mode::in_2D
|
||||
);
|
||||
_model_instance_storage.for_each_wmo_instance(
|
||||
[&](WMOInstance &wmo)
|
||||
{
|
||||
if (settings->use_filters)
|
||||
{
|
||||
bool found_model = false;
|
||||
bool found_instance = false;
|
||||
|
||||
});
|
||||
for (int i = 0; i < settings->wmo_model_filter_exclude->count(); ++i)
|
||||
{
|
||||
auto item_wgt_m = reinterpret_cast<noggit::ui::MinimapWMOModelFilterEntry*>(
|
||||
settings->wmo_model_filter_exclude->itemWidget(settings->wmo_model_filter_exclude->item(i)));
|
||||
|
||||
if (item_wgt_m->getFileName().toStdString() == wmo.wmo->filename)
|
||||
{
|
||||
found_model = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < settings->wmo_instance_filter_exclude->count(); ++i)
|
||||
{
|
||||
auto item_wgt_i = reinterpret_cast<noggit::ui::MinimapInstanceFilterEntry*>(
|
||||
settings->wmo_instance_filter_exclude->itemWidget(settings->wmo_instance_filter_exclude->item(i)));
|
||||
|
||||
if (item_wgt_i->getUid() == wmo.mUniqueID)
|
||||
{
|
||||
found_instance = true;
|
||||
}
|
||||
}
|
||||
|
||||
// For WMOs we exclude models from rendering
|
||||
if (found_model || found_instance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wmo.wmo->wait_until_loaded();
|
||||
wmo.draw(wmo_program, model_view, projection, frustum,
|
||||
culldistance, camera_pos, false, false,
|
||||
false, _liquid_render.get(), current_selection(),
|
||||
animtime, skies->hasSkies(), display_mode::in_2D
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
gl.enable(GL_BLEND);
|
||||
gl.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -2016,9 +2084,23 @@ void World::drawMinimap ( MapTile *tile
|
||||
-1, display_mode::in_2D
|
||||
);
|
||||
|
||||
if (mTile)
|
||||
{
|
||||
mTile->wait_until_loaded();
|
||||
|
||||
mTile->drawWater(frustum, culldistance, camera_pos, true, _liquid_render.get(), water_shader, animtime,
|
||||
-1, display_mode::in_2D
|
||||
);
|
||||
}
|
||||
|
||||
gl.bindVertexArray(0);
|
||||
gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
if (unload)
|
||||
{
|
||||
mapIndex.unloadTile(m_tile);
|
||||
}
|
||||
}
|
||||
|
||||
bool World::saveMinimap(tile_index const& tile_idx, MinimapRenderSettings* settings)
|
||||
@@ -2074,7 +2156,19 @@ bool World::saveMinimap(tile_index const& tile_idx, MinimapRenderSettings* setti
|
||||
, settings);
|
||||
|
||||
QImage image = pixel_buffer.toImage();
|
||||
image.save(("/Users/sshumakov/Desktop/MinimapGenTest/test_" + std::to_string(tile_idx.x) + "_" + std::to_string(tile_idx.z) + ".png").c_str());
|
||||
|
||||
QSettings settings;
|
||||
QString str = settings.value ("project/path").toString();
|
||||
if (!(str.endsWith('\\') || str.endsWith('/')))
|
||||
{
|
||||
str += "/";
|
||||
}
|
||||
|
||||
QDir dir(str + "/textures/minimap/");
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
image.save(dir.filePath(std::string(basename + "_" + std::to_string(tile_idx.x) + "_" + std::to_string(tile_idx.z) + ".png").c_str()));
|
||||
|
||||
if (unload)
|
||||
{
|
||||
|
||||
@@ -161,6 +161,7 @@ public:
|
||||
boost::optional<selection_type> get_last_selected_model() const;
|
||||
bool has_selection() const { return !_current_selection.empty(); }
|
||||
bool has_multiple_model_selected() const { return _selected_model_count > 1; }
|
||||
int get_selected_model_count() const { return _selected_model_count; }
|
||||
void set_current_selection(selection_type entry);
|
||||
void add_to_selection(selection_type entry);
|
||||
void remove_from_selection(selection_type entry);
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
|
||||
#include "revision.h"
|
||||
|
||||
#include <noggit/ui/style/framelesswindow/framelesswindow.h>
|
||||
#include <noggit/ui/style/DarkStyle.h>
|
||||
|
||||
class Noggit
|
||||
{
|
||||
public:
|
||||
@@ -284,7 +287,11 @@ Noggit::Noggit(int argc, char *argv[])
|
||||
LogDebug << "GL: Vendor: " << gl.getString (GL_VENDOR) << std::endl;
|
||||
LogDebug << "GL: Renderer: " << gl.getString (GL_RENDERER) << std::endl;
|
||||
|
||||
|
||||
qApp->setStyle(new DarkStyle);
|
||||
|
||||
main_window = std::make_unique<noggit::ui::main_window>();
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
main_window->showFullScreen();
|
||||
|
||||
@@ -70,7 +70,8 @@ enum class editing_mode
|
||||
water,
|
||||
mccv,
|
||||
object,
|
||||
minimap
|
||||
minimap,
|
||||
stamp
|
||||
};
|
||||
|
||||
enum water_opacity
|
||||
|
||||
@@ -125,42 +125,292 @@ namespace noggit
|
||||
draw_elevation->setChecked(_render_settings.draw_elevation);
|
||||
render_settings_box_layout->addRow (draw_elevation);
|
||||
|
||||
auto use_filters = new QCheckBox("Use filters", render_settings_box);
|
||||
use_filters->setChecked(_render_settings.use_filters);
|
||||
render_settings_box_layout->addRow (use_filters);
|
||||
|
||||
_progress_bar = new QProgressBar(this);
|
||||
_progress_bar->setRange(0, 4096);
|
||||
generate_layout->addRow (_progress_bar);
|
||||
|
||||
// Filter
|
||||
auto filter_widget = new QWidget(this);
|
||||
filter_widget->setContentsMargins(0, 0, 0, 0);
|
||||
auto filter_layout = new QFormLayout(filter_widget);
|
||||
filter_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
settings_tabs->addTab(filter_widget, "Filter");
|
||||
|
||||
auto m2_include_box = new QGroupBox("Render options", filter_widget);
|
||||
filter_layout->addRow(m2_include_box);
|
||||
auto filter_tabs = new QTabWidget(filter_widget);
|
||||
filter_tabs->setTabPosition(QTabWidget::East);
|
||||
filter_tabs->setDocumentMode(true);
|
||||
filter_layout->addRow(filter_tabs);
|
||||
|
||||
auto m2_include_box_layout = new QFormLayout (m2_include_box);
|
||||
// M2 model include tab
|
||||
auto m2_include_widget = new QWidget(filter_tabs);
|
||||
filter_tabs->addTab(m2_include_widget, "M2 Model");
|
||||
|
||||
_m2_model_filter_include = new QListWidget(m2_include_box);
|
||||
auto m2_include_box_layout = new QFormLayout(m2_include_widget);
|
||||
m2_include_box_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m2_include_widget->setLayout(m2_include_box_layout);
|
||||
|
||||
auto search_filter_m2 = new QLineEdit(this);
|
||||
search_filter_m2->setMinimumWidth(220);
|
||||
m2_include_box_layout->addRow("Filter:", search_filter_m2);
|
||||
|
||||
_m2_model_filter_include = new QListWidget(m2_include_widget);
|
||||
_render_settings.m2_model_filter_include = _m2_model_filter_include;
|
||||
_m2_model_filter_include->setAlternatingRowColors(true);
|
||||
|
||||
m2_include_box_layout->addRow(_m2_model_filter_include);
|
||||
|
||||
auto m2_include_box_layout_btns = new QHBoxLayout(m2_include_box);
|
||||
auto m2_include_box_layout_btns = new QHBoxLayout(m2_include_widget);
|
||||
m2_include_box_layout->addRow(m2_include_box_layout_btns);
|
||||
|
||||
auto add_btn = new QPushButton(m2_include_box);
|
||||
auto add_btn = new QPushButton("Add", m2_include_widget);
|
||||
add_btn->setIcon(font_awesome_icon(font_awesome::plus));
|
||||
m2_include_box_layout_btns->addWidget(add_btn);
|
||||
|
||||
auto remove_btn = new QPushButton(m2_include_box);
|
||||
auto remove_btn = new QPushButton("Remove", m2_include_widget);
|
||||
remove_btn->setIcon(font_awesome_icon(font_awesome::timescircle));
|
||||
m2_include_box_layout_btns->addWidget(remove_btn);
|
||||
|
||||
auto clear_btn = new QPushButton("Clear all", m2_include_widget);
|
||||
clear_btn->setIcon(font_awesome_icon(font_awesome::trash));
|
||||
m2_include_box_layout_btns->addWidget(clear_btn);
|
||||
|
||||
// M2 instance include tab
|
||||
auto m2_instance_include_widget = new QWidget(filter_tabs);
|
||||
filter_tabs->addTab(m2_instance_include_widget, "M2 Instance");
|
||||
|
||||
auto m2_instance_include_box_layout = new QFormLayout(m2_instance_include_widget);
|
||||
m2_instance_include_box_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m2_instance_include_widget->setLayout(m2_instance_include_box_layout);
|
||||
|
||||
auto search_filter_m2i = new QLineEdit(this);
|
||||
search_filter_m2i->setMinimumWidth(220);
|
||||
m2_instance_include_box_layout->addRow("Filter:", search_filter_m2i);
|
||||
|
||||
_m2_instance_filter_include = new QListWidget(m2_instance_include_widget);
|
||||
_render_settings.m2_instance_filter_include = _m2_instance_filter_include;
|
||||
_m2_instance_filter_include->setAlternatingRowColors(true);
|
||||
|
||||
m2_instance_include_box_layout->addRow(_m2_instance_filter_include);
|
||||
|
||||
auto m2_instance_include_box_layout_btns = new QHBoxLayout(m2_instance_include_widget);
|
||||
m2_instance_include_box_layout->addRow(m2_instance_include_box_layout_btns);
|
||||
|
||||
auto add_btn_m2i = new QPushButton("Add", m2_instance_include_widget);
|
||||
add_btn_m2i->setIcon(font_awesome_icon(font_awesome::plus));
|
||||
m2_instance_include_box_layout_btns->addWidget(add_btn_m2i);
|
||||
|
||||
auto remove_btn_m2i = new QPushButton("Remove", m2_instance_include_widget);
|
||||
remove_btn_m2i->setIcon(font_awesome_icon(font_awesome::timescircle));
|
||||
m2_instance_include_box_layout_btns->addWidget(remove_btn_m2i);
|
||||
|
||||
auto clear_btn_m2i = new QPushButton("Clear all", m2_instance_include_widget);
|
||||
clear_btn_m2i->setIcon(font_awesome_icon(font_awesome::trash));
|
||||
m2_instance_include_box_layout_btns->addWidget(clear_btn_m2i);
|
||||
|
||||
// WMO model exclude tab
|
||||
auto wmo_exclude_widget = new QWidget(filter_tabs);
|
||||
filter_tabs->addTab(wmo_exclude_widget, "WMO Model");
|
||||
|
||||
auto wmo_exclude_box_layout = new QFormLayout(wmo_exclude_widget);
|
||||
wmo_exclude_box_layout->setContentsMargins(0, 0, 0, 0);
|
||||
wmo_exclude_widget->setLayout(wmo_exclude_box_layout);
|
||||
|
||||
auto search_filter_wmo = new QLineEdit(this);
|
||||
search_filter_wmo->setMinimumWidth(220);
|
||||
wmo_exclude_box_layout->addRow("Filter:", search_filter_wmo);
|
||||
|
||||
_wmo_model_filter_exclude = new QListWidget(wmo_exclude_widget);
|
||||
_render_settings.wmo_model_filter_exclude = _wmo_model_filter_exclude;
|
||||
_wmo_model_filter_exclude->setAlternatingRowColors(true);
|
||||
|
||||
wmo_exclude_box_layout->addRow(_wmo_model_filter_exclude);
|
||||
|
||||
auto wmo_exclude_box_layout_btns = new QHBoxLayout(wmo_exclude_widget);
|
||||
wmo_exclude_box_layout->addRow(wmo_exclude_box_layout_btns);
|
||||
|
||||
auto add_btn_wmo = new QPushButton("Add", wmo_exclude_widget);
|
||||
add_btn_wmo->setIcon(font_awesome_icon(font_awesome::plus));
|
||||
wmo_exclude_box_layout_btns->addWidget(add_btn_wmo);
|
||||
|
||||
auto remove_btn_wmo = new QPushButton("Remove", wmo_exclude_widget);
|
||||
remove_btn_wmo->setIcon(font_awesome_icon(font_awesome::timescircle));
|
||||
wmo_exclude_box_layout_btns->addWidget(remove_btn_wmo);
|
||||
|
||||
auto clear_btn_wmo = new QPushButton("Clear all", wmo_exclude_widget);
|
||||
clear_btn_wmo->setIcon(font_awesome_icon(font_awesome::trash));
|
||||
wmo_exclude_box_layout_btns->addWidget(clear_btn_wmo);
|
||||
|
||||
// WMO instance exclude tab
|
||||
auto wmo_instance_exclude_widget = new QWidget(filter_tabs);
|
||||
filter_tabs->addTab(wmo_instance_exclude_widget, "WMO Instance");
|
||||
|
||||
auto wmo_instance_exclude_box_layout = new QFormLayout(wmo_instance_exclude_widget);
|
||||
wmo_instance_exclude_box_layout->setContentsMargins(0, 0, 0, 0);
|
||||
wmo_instance_exclude_widget->setLayout(wmo_instance_exclude_box_layout);
|
||||
|
||||
auto search_filter_wmo_i = new QLineEdit(this);
|
||||
search_filter_wmo_i->setMinimumWidth(220);
|
||||
wmo_instance_exclude_box_layout->addRow("Filter:", search_filter_wmo_i);
|
||||
|
||||
_wmo_instance_filter_exclude = new QListWidget(wmo_instance_exclude_widget);
|
||||
_render_settings.wmo_instance_filter_exclude = _wmo_instance_filter_exclude;
|
||||
_wmo_instance_filter_exclude->setAlternatingRowColors(true);
|
||||
|
||||
wmo_instance_exclude_box_layout->addRow(_wmo_instance_filter_exclude);
|
||||
|
||||
auto wmo_instance_exclude_box_layout_btns = new QHBoxLayout(wmo_instance_exclude_widget);
|
||||
wmo_instance_exclude_box_layout->addRow(wmo_instance_exclude_box_layout_btns);
|
||||
|
||||
auto add_btn_wmo_i = new QPushButton("Add", wmo_instance_exclude_widget);
|
||||
add_btn_wmo_i->setIcon(font_awesome_icon(font_awesome::plus));
|
||||
wmo_instance_exclude_box_layout_btns->addWidget(add_btn_wmo_i);
|
||||
|
||||
auto remove_btn_wmo_i = new QPushButton("Remove", wmo_instance_exclude_widget);
|
||||
remove_btn_wmo_i->setIcon(font_awesome_icon(font_awesome::timescircle));
|
||||
wmo_instance_exclude_box_layout_btns->addWidget(remove_btn_wmo_i);
|
||||
|
||||
auto clear_btn_wmo_i = new QPushButton("Clear all", wmo_instance_exclude_widget);
|
||||
clear_btn_wmo_i->setIcon(font_awesome_icon(font_awesome::trash));
|
||||
wmo_instance_exclude_box_layout_btns->addWidget(clear_btn_wmo_i);
|
||||
|
||||
// Lighting
|
||||
|
||||
auto lighting_widget = new QWidget(this);
|
||||
auto lighting_layout = new QFormLayout(filter_widget);
|
||||
lighting_widget->setLayout(lighting_layout);
|
||||
|
||||
settings_tabs->addTab(lighting_widget, "Lighting");
|
||||
|
||||
auto diffuse_color = new color_widgets::ColorSelector (this);
|
||||
diffuse_color->setDisplayMode (color_widgets::ColorSelector::NoAlpha);
|
||||
diffuse_color->setColor (QColor::fromRgbF (_render_settings.diffuse_color.x,
|
||||
_render_settings.diffuse_color.y,
|
||||
_render_settings.diffuse_color.z));
|
||||
diffuse_color->setMinimumHeight(25);
|
||||
|
||||
lighting_layout->addRow("Diffuse color:", diffuse_color);
|
||||
|
||||
auto ambient_color = new color_widgets::ColorSelector (this);
|
||||
ambient_color->setDisplayMode (color_widgets::ColorSelector::NoAlpha);
|
||||
ambient_color->setColor (QColor::fromRgbF (_render_settings.ambient_color.x,
|
||||
_render_settings.ambient_color.y,
|
||||
_render_settings.ambient_color.z));
|
||||
ambient_color->setMinimumHeight(25);
|
||||
|
||||
lighting_layout->addRow("Ambient color:", ambient_color);
|
||||
|
||||
auto ocean_color_light = new color_widgets::ColorSelector (this);
|
||||
ocean_color_light->setColor (QColor::fromRgbF (_render_settings.ocean_color_light.x,
|
||||
_render_settings.ocean_color_light.y,
|
||||
_render_settings.ocean_color_light.z,
|
||||
_render_settings.ocean_color_light.w));
|
||||
ocean_color_light->setMinimumHeight(25);
|
||||
|
||||
lighting_layout->addRow("Ocean light color:", ocean_color_light);
|
||||
|
||||
auto ocean_color_dark = new color_widgets::ColorSelector (this);
|
||||
ocean_color_dark->setColor (QColor::fromRgbF (_render_settings.ocean_color_dark.x,
|
||||
_render_settings.ocean_color_dark.y,
|
||||
_render_settings.ocean_color_dark.z,
|
||||
_render_settings.ocean_color_dark.w));
|
||||
ocean_color_dark->setMinimumHeight(25);
|
||||
|
||||
lighting_layout->addRow("Ocean dakr color:", ocean_color_dark);
|
||||
|
||||
auto river_color_light = new color_widgets::ColorSelector (this);
|
||||
river_color_light->setColor (QColor::fromRgbF (_render_settings.river_color_light.x,
|
||||
_render_settings.river_color_light.y,
|
||||
_render_settings.river_color_light.z,
|
||||
_render_settings.river_color_light.w));
|
||||
river_color_light->setMinimumHeight(25);
|
||||
|
||||
lighting_layout->addRow("River light color:", river_color_light);
|
||||
|
||||
auto river_color_dark = new color_widgets::ColorSelector (this);
|
||||
river_color_dark->setColor (QColor::fromRgbF (_render_settings.river_color_dark.x,
|
||||
_render_settings.river_color_dark.y,
|
||||
_render_settings.river_color_dark.z,
|
||||
_render_settings.river_color_dark.w));
|
||||
river_color_dark->setMinimumHeight(25);
|
||||
|
||||
lighting_layout->addRow("River dark color:", river_color_dark);
|
||||
|
||||
// Connections
|
||||
|
||||
// Filter buttons
|
||||
|
||||
// Lighting colors
|
||||
connect(diffuse_color, &color_widgets::ColorSelector::colorChanged,
|
||||
[this] (QColor new_color)
|
||||
{
|
||||
|
||||
_render_settings.diffuse_color = {static_cast<float>(new_color.redF()),
|
||||
static_cast<float>(new_color.greenF()),
|
||||
static_cast<float>(new_color.blueF())};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
connect(ambient_color, &color_widgets::ColorSelector::colorChanged,
|
||||
[this] (QColor new_color)
|
||||
{
|
||||
|
||||
_render_settings.ambient_color = {static_cast<float>(new_color.redF()),
|
||||
static_cast<float>(new_color.greenF()),
|
||||
static_cast<float>(new_color.blueF())};
|
||||
}
|
||||
);
|
||||
|
||||
connect(ocean_color_light, &color_widgets::ColorSelector::colorChanged,
|
||||
[this] (QColor new_color)
|
||||
{
|
||||
|
||||
_render_settings.ocean_color_light = {static_cast<float>(new_color.redF()),
|
||||
static_cast<float>(new_color.greenF()),
|
||||
static_cast<float>(new_color.blueF()),
|
||||
static_cast<float>(new_color.alphaF())};
|
||||
}
|
||||
);
|
||||
|
||||
connect(ocean_color_dark, &color_widgets::ColorSelector::colorChanged,
|
||||
[this] (QColor new_color)
|
||||
{
|
||||
|
||||
_render_settings.ocean_color_dark = {static_cast<float>(new_color.redF()),
|
||||
static_cast<float>(new_color.greenF()),
|
||||
static_cast<float>(new_color.blueF()),
|
||||
static_cast<float>(new_color.alphaF())};
|
||||
}
|
||||
);
|
||||
|
||||
connect(river_color_light, &color_widgets::ColorSelector::colorChanged,
|
||||
[this] (QColor new_color)
|
||||
{
|
||||
|
||||
_render_settings.river_color_light = {static_cast<float>(new_color.redF()),
|
||||
static_cast<float>(new_color.greenF()),
|
||||
static_cast<float>(new_color.blueF()),
|
||||
static_cast<float>(new_color.alphaF())};
|
||||
}
|
||||
);
|
||||
|
||||
connect(river_color_dark , &color_widgets::ColorSelector::colorChanged,
|
||||
[this] (QColor new_color)
|
||||
{
|
||||
|
||||
_render_settings.river_color_dark = {static_cast<float>(new_color.redF()),
|
||||
static_cast<float>(new_color.greenF()),
|
||||
static_cast<float>(new_color.blueF()),
|
||||
static_cast<float>(new_color.alphaF())};
|
||||
}
|
||||
);
|
||||
|
||||
// M2 model filter
|
||||
connect(add_btn, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
@@ -171,17 +421,9 @@ namespace noggit
|
||||
|
||||
for (auto& selection : world->current_selection())
|
||||
{
|
||||
if (selection.which() == eEntry_MapChunk)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string path;
|
||||
|
||||
if (selection.which() == eEntry_Model)
|
||||
{
|
||||
path = boost::get<selected_model_type>(selection)->model->filename;
|
||||
includeM2Model(path);
|
||||
includeM2Model(boost::get<selected_model_type>(selection)->model->filename);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -192,12 +434,98 @@ namespace noggit
|
||||
connect(remove_btn, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
for (auto item : _m2_model_filter_include->selectedItems())
|
||||
|
||||
if (!world->get_selected_model_count())
|
||||
{
|
||||
auto item_ = _m2_model_filter_include->takeItem(_m2_model_filter_include->row(item));
|
||||
delete item_;
|
||||
for (auto item : _m2_model_filter_include->selectedItems())
|
||||
{
|
||||
auto item_ = _m2_model_filter_include->takeItem(_m2_model_filter_include->row(item));
|
||||
delete item_;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& selection : world->current_selection())
|
||||
{
|
||||
if (selection.which() == eEntry_Model)
|
||||
{
|
||||
unincludeM2Model(boost::get<selected_model_type>(selection)->model->filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
connect(clear_btn, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
_m2_model_filter_include->clear();
|
||||
}
|
||||
);
|
||||
|
||||
// M2 instance filter
|
||||
connect(add_btn_m2i, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
if (!world->has_selection())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& selection : world->current_selection())
|
||||
{
|
||||
if (selection.which() == eEntry_Model)
|
||||
{
|
||||
includeM2Instance(boost::get<selected_model_type>(selection)->uid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
connect(remove_btn_m2i, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
|
||||
if (!world->get_selected_model_count())
|
||||
{
|
||||
for (auto item : _m2_instance_filter_include->selectedItems())
|
||||
{
|
||||
auto item_ = _m2_instance_filter_include->takeItem(_m2_instance_filter_include->row(item));
|
||||
delete item_;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& selection : world->current_selection())
|
||||
{
|
||||
|
||||
if (selection.which() == eEntry_Model)
|
||||
{
|
||||
unincludeM2Instance(boost::get<selected_model_type>(selection)->uid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
connect(clear_btn_m2i, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
_m2_instance_filter_include->clear();
|
||||
}
|
||||
);
|
||||
|
||||
// WMO model filter
|
||||
connect(add_btn_wmo, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
if (!world->has_selection())
|
||||
{
|
||||
return;
|
||||
@@ -205,17 +533,9 @@ namespace noggit
|
||||
|
||||
for (auto& selection : world->current_selection())
|
||||
{
|
||||
if (selection.which() == eEntry_MapChunk)
|
||||
if (selection.which() == eEntry_WMO)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string path;
|
||||
|
||||
if (selection.which() == eEntry_Model)
|
||||
{
|
||||
path = boost::get<selected_model_type>(selection)->model->filename;
|
||||
unincludeM2Model(path);
|
||||
excludeWMOModel(boost::get<selected_wmo_type>(selection)->wmo->filename);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -223,6 +543,163 @@ namespace noggit
|
||||
}
|
||||
);
|
||||
|
||||
connect(remove_btn_wmo, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
|
||||
if (!world->get_selected_model_count())
|
||||
{
|
||||
for (auto item : _wmo_model_filter_exclude->selectedItems())
|
||||
{
|
||||
auto item_ = _wmo_model_filter_exclude->takeItem(_wmo_model_filter_exclude->row(item));
|
||||
delete item_;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& selection : world->current_selection())
|
||||
{
|
||||
|
||||
if (selection.which() == eEntry_WMO)
|
||||
{
|
||||
unexcludeWMOModel(boost::get<selected_wmo_type>(selection)->wmo->filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
connect(clear_btn_wmo, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
_wmo_model_filter_exclude->clear();
|
||||
}
|
||||
);
|
||||
|
||||
// WMO instance filter
|
||||
connect(add_btn_wmo_i, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
if (!world->has_selection())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& selection : world->current_selection())
|
||||
{
|
||||
if (selection.which() == eEntry_WMO)
|
||||
{
|
||||
excludeWMOInstance(boost::get<selected_wmo_type>(selection)->mUniqueID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
connect(remove_btn_wmo_i, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
|
||||
if (!world->get_selected_model_count())
|
||||
{
|
||||
for (auto item : _wmo_instance_filter_exclude->selectedItems())
|
||||
{
|
||||
auto item_ = _wmo_instance_filter_exclude->takeItem(_wmo_instance_filter_exclude->row(item));
|
||||
delete item_;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& selection : world->current_selection())
|
||||
{
|
||||
|
||||
if (selection.which() == eEntry_WMO)
|
||||
{
|
||||
unexcludeWMOInstance(boost::get<selected_wmo_type>(selection)->mUniqueID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
connect(clear_btn_wmo_i, &QPushButton::clicked,
|
||||
[=]()
|
||||
{
|
||||
_wmo_instance_filter_exclude->clear();
|
||||
}
|
||||
);
|
||||
|
||||
// Search filters
|
||||
|
||||
connect ( search_filter_m2, qOverload<const QString&> (&QLineEdit::textChanged)
|
||||
, [&] (const QString& s)
|
||||
{
|
||||
for (int i = 0; i < _m2_model_filter_include->count(); ++i)
|
||||
{
|
||||
MinimapM2ModelFilterEntry* item_wgt = reinterpret_cast<MinimapM2ModelFilterEntry*>(
|
||||
_m2_model_filter_include->itemWidget(_m2_model_filter_include->item(i)));
|
||||
|
||||
std::string filename = item_wgt->getFileName().toStdString();
|
||||
std::string filter = s.toStdString();
|
||||
bool isHidden = !filter.empty() && filename.find(filter) == std::string::npos;
|
||||
_m2_model_filter_include->item(i)->setHidden(isHidden);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
connect ( search_filter_m2i, qOverload<const QString&> (&QLineEdit::textChanged)
|
||||
, [&] (const QString& s)
|
||||
{
|
||||
for (int i = 0; i < _m2_instance_filter_include->count(); ++i)
|
||||
{
|
||||
MinimapInstanceFilterEntry* item_wgt = reinterpret_cast<MinimapInstanceFilterEntry*>(
|
||||
_m2_instance_filter_include->itemWidget(_m2_instance_filter_include->item(i)));
|
||||
|
||||
std::string uid = std::to_string(item_wgt->getUid());
|
||||
std::string filter = s.toStdString();
|
||||
bool isHidden = !filter.empty() && uid.find(filter) == std::string::npos;
|
||||
_m2_instance_filter_include->item(i)->setHidden(isHidden);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
connect ( search_filter_wmo, qOverload<const QString&> (&QLineEdit::textChanged)
|
||||
, [&] (const QString& s)
|
||||
{
|
||||
for (int i = 0; i < _wmo_model_filter_exclude->count(); ++i)
|
||||
{
|
||||
MinimapWMOModelFilterEntry* item_wgt = reinterpret_cast<MinimapWMOModelFilterEntry*>(
|
||||
_wmo_model_filter_exclude->itemWidget(_wmo_model_filter_exclude->item(i)));
|
||||
|
||||
std::string filename = item_wgt->getFileName().toStdString();
|
||||
std::string filter = s.toStdString();
|
||||
bool isHidden = !filter.empty() && filename.find(filter) == std::string::npos;
|
||||
_wmo_model_filter_exclude->item(i)->setHidden(isHidden);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
connect ( search_filter_wmo_i, qOverload<const QString&> (&QLineEdit::textChanged)
|
||||
, [&] (const QString& s)
|
||||
{
|
||||
for (int i = 0; i < _wmo_instance_filter_exclude->count(); ++i)
|
||||
{
|
||||
MinimapInstanceFilterEntry* item_wgt = reinterpret_cast<MinimapInstanceFilterEntry*>(
|
||||
_wmo_instance_filter_exclude->itemWidget(_wmo_instance_filter_exclude->item(i)));
|
||||
|
||||
std::string uid = std::to_string(item_wgt->getUid());
|
||||
std::string filter = s.toStdString();
|
||||
bool isHidden = !filter.empty() && uid.find(filter) == std::string::npos;
|
||||
_wmo_instance_filter_exclude->item(i)->setHidden(isHidden);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
connect ( _radius_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
|
||||
, [&] (double v)
|
||||
{
|
||||
@@ -275,6 +752,11 @@ namespace noggit
|
||||
_render_settings.draw_elevation = s;
|
||||
});
|
||||
|
||||
connect (use_filters, &QCheckBox::stateChanged, [this] (int s)
|
||||
{
|
||||
_render_settings.use_filters = s;
|
||||
});
|
||||
|
||||
// Buttons
|
||||
connect(cur_adt_btn, &QPushButton::clicked, [=]() {
|
||||
_render_settings.export_mode = MinimapGenMode::CURRENT_ADT;
|
||||
@@ -416,16 +898,154 @@ namespace noggit
|
||||
|
||||
}
|
||||
|
||||
void MinimapCreator::includeM2Instance(uint32_t uid)
|
||||
{
|
||||
bool already_added = false;
|
||||
|
||||
for (int i = 0; i < _m2_instance_filter_include->count(); ++i)
|
||||
{
|
||||
if (reinterpret_cast<MinimapInstanceFilterEntry*>(_m2_instance_filter_include->itemWidget(
|
||||
_m2_instance_filter_include->item(i)))->getUid() == uid)
|
||||
{
|
||||
already_added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (already_added)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto item = new QListWidgetItem();
|
||||
_m2_instance_filter_include->addItem(item);
|
||||
auto entry_wgt = new MinimapInstanceFilterEntry(this);
|
||||
entry_wgt->setUid(uid);
|
||||
item->setSizeHint(entry_wgt->minimumSizeHint());
|
||||
_m2_instance_filter_include->setItemWidget(item, entry_wgt);
|
||||
}
|
||||
|
||||
void MinimapCreator::unincludeM2Instance(uint32_t uid)
|
||||
{
|
||||
for (int i = 0; i < _m2_model_filter_include->count(); ++i )
|
||||
{
|
||||
if (reinterpret_cast<MinimapInstanceFilterEntry*>(_m2_instance_filter_include->itemWidget(
|
||||
_m2_instance_filter_include->item(i)))->getUid() == uid)
|
||||
{
|
||||
auto item = _m2_model_filter_include->takeItem(i);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MinimapCreator::excludeWMOModel(std::string filename)
|
||||
{
|
||||
bool already_added = false;
|
||||
|
||||
for (int i = 0; i < _wmo_model_filter_exclude->count(); ++i)
|
||||
{
|
||||
if (!reinterpret_cast<MinimapWMOModelFilterEntry*>(_wmo_model_filter_exclude->itemWidget(
|
||||
_wmo_model_filter_exclude->item(i)))->getFileName().toStdString().compare(filename))
|
||||
{
|
||||
already_added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (already_added)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto item = new QListWidgetItem();
|
||||
_wmo_model_filter_exclude->addItem(item);
|
||||
auto entry_wgt = new MinimapWMOModelFilterEntry(this);
|
||||
entry_wgt->setFileName(filename);
|
||||
item->setSizeHint(entry_wgt->minimumSizeHint());
|
||||
_wmo_model_filter_exclude->setItemWidget(item, entry_wgt);
|
||||
}
|
||||
|
||||
void MinimapCreator::unexcludeWMOModel(std::string filename)
|
||||
{
|
||||
|
||||
for (int i = 0; i < _wmo_model_filter_exclude->count(); ++i )
|
||||
{
|
||||
if (!reinterpret_cast<MinimapWMOModelFilterEntry*>(_wmo_model_filter_exclude->itemWidget(
|
||||
_wmo_model_filter_exclude->item(i)))->getFileName().toStdString().compare(filename))
|
||||
{
|
||||
auto item = _wmo_model_filter_exclude->takeItem(i);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MinimapCreator::excludeWMOInstance(uint32_t uid)
|
||||
{
|
||||
bool already_added = false;
|
||||
|
||||
for (int i = 0; i < _wmo_instance_filter_exclude->count(); ++i)
|
||||
{
|
||||
if (reinterpret_cast<MinimapInstanceFilterEntry*>(_wmo_instance_filter_exclude->itemWidget(
|
||||
_wmo_instance_filter_exclude->item(i)))->getUid() == uid)
|
||||
{
|
||||
already_added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (already_added)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto item = new QListWidgetItem();
|
||||
_wmo_instance_filter_exclude->addItem(item);
|
||||
auto entry_wgt = new MinimapInstanceFilterEntry(this);
|
||||
entry_wgt->setUid(uid);
|
||||
item->setSizeHint(entry_wgt->minimumSizeHint());
|
||||
_wmo_instance_filter_exclude->setItemWidget(item, entry_wgt);
|
||||
}
|
||||
|
||||
void MinimapCreator::unexcludeWMOInstance(uint32_t uid)
|
||||
{
|
||||
for (int i = 0; i < _wmo_instance_filter_exclude->count(); ++i )
|
||||
{
|
||||
if (reinterpret_cast<MinimapInstanceFilterEntry*>(_wmo_instance_filter_exclude->itemWidget(
|
||||
_wmo_instance_filter_exclude->item(i)))->getUid() == uid)
|
||||
{
|
||||
auto item = _wmo_instance_filter_exclude->takeItem(i);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MinimapM2ModelFilterEntry::MinimapM2ModelFilterEntry(MinimapCreator* parent) : QWidget(parent)
|
||||
{
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(5, 2, 5, 2);
|
||||
layout->addWidget(_filename = new QLineEdit(this));
|
||||
_filename->setEnabled(false);
|
||||
layout->addWidget(_size_category_spin = new QDoubleSpinBox(this));
|
||||
_size_category_spin->setRange (0.0f, 100.0f);
|
||||
_size_category_spin->setDecimals (2);
|
||||
_size_category_spin->setRange (0.0f, 1000.0f);
|
||||
_size_category_spin->setValue (0.0);
|
||||
|
||||
}
|
||||
|
||||
MinimapWMOModelFilterEntry::MinimapWMOModelFilterEntry(MinimapCreator* parent) : QWidget(parent)
|
||||
{
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->addWidget(_filename = new QLineEdit(this));
|
||||
layout->setContentsMargins(5, 2, 5, 2);
|
||||
_filename->setEnabled(false);
|
||||
}
|
||||
|
||||
MinimapInstanceFilterEntry::MinimapInstanceFilterEntry(MinimapCreator* parent) : QWidget(parent)
|
||||
{
|
||||
auto layout = new QHBoxLayout(this);
|
||||
layout->addWidget(_uid_label = new QLabel(this));
|
||||
layout->setContentsMargins(5, 2, 5, 2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,20 +4,25 @@
|
||||
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include <QtWidgets/QSlider>
|
||||
#include <QSlider>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QSpinBox>
|
||||
#include <QProgressBar>
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
#include <qt-color-widgets/color_selector.hpp>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <math/vector_4d.hpp>
|
||||
#include <math/vector_3d.hpp>
|
||||
|
||||
#include <noggit/ui/minimap_widget.hpp>
|
||||
|
||||
|
||||
class MapView;
|
||||
class World;
|
||||
|
||||
@@ -30,7 +35,7 @@ enum MinimapGenMode
|
||||
|
||||
struct MinimapRenderSettings
|
||||
{
|
||||
MinimapGenMode export_mode; // Export mode
|
||||
MinimapGenMode export_mode;
|
||||
|
||||
// Render settings
|
||||
int resolution = 512;
|
||||
@@ -39,19 +44,24 @@ struct MinimapRenderSettings
|
||||
bool draw_water = true;
|
||||
bool draw_adt_grid = false;
|
||||
bool draw_elevation = false;
|
||||
bool use_filters = false;
|
||||
|
||||
// Selection
|
||||
std::array<bool, 4096> selected_tiles = {false};
|
||||
|
||||
QListWidget* m2_model_filter_include;
|
||||
|
||||
// Filtering
|
||||
/*
|
||||
std::unordered_map<std::string, float> m2_model_filter_include; // filename, size category
|
||||
std::vector<uint32_t> m2_instance_filter_include; // include specific M2 instances
|
||||
std::vector<std::string> wmo_model_filter_exclude; // exclude WMOs by filename
|
||||
std::vector<uint32_t> wmo_instance_filter_exclude; // exclude specific WMO instances
|
||||
*/
|
||||
QListWidget* m2_model_filter_include;
|
||||
QListWidget* m2_instance_filter_include;
|
||||
QListWidget* wmo_model_filter_exclude;
|
||||
QListWidget* wmo_instance_filter_exclude;
|
||||
|
||||
// Lighting
|
||||
math::vector_3d diffuse_color = {1.0, 0.532352924, 0.0};
|
||||
math::vector_3d ambient_color = {0.407770514, 0.508424163, 0.602650642};
|
||||
math::vector_4d ocean_color_light = {0.0693173409, 0.294008732, 0.348329663, 0.75};
|
||||
math::vector_4d ocean_color_dark = {0.000762581825, 0.113907099, 0.161220074, 1.0};
|
||||
math::vector_4d river_color_light = {0.308351517, 0.363725543, 0.0798838138, 0.5};
|
||||
math::vector_4d river_color_dark = {0.19945538, 0.320697188, 0.332425594, 1.0};
|
||||
|
||||
};
|
||||
|
||||
@@ -82,6 +92,14 @@ namespace noggit
|
||||
|
||||
void includeM2Model(std::string filename);
|
||||
void unincludeM2Model(std::string filename);
|
||||
void includeM2Instance(uint32_t uid);
|
||||
void unincludeM2Instance(uint32_t uid);
|
||||
|
||||
void excludeWMOModel(std::string filename);
|
||||
void unexcludeWMOModel(std::string filename);
|
||||
void excludeWMOInstance(uint32_t uid);
|
||||
void unexcludeWMOInstance(uint32_t uid);
|
||||
|
||||
|
||||
private:
|
||||
float _radius = 0.01f;
|
||||
@@ -91,6 +109,9 @@ namespace noggit
|
||||
minimap_widget* _minimap_widget;
|
||||
QProgressBar* _progress_bar;
|
||||
QListWidget* _m2_model_filter_include;
|
||||
QListWidget* _m2_instance_filter_include;
|
||||
QListWidget* _wmo_model_filter_exclude;
|
||||
QListWidget* _wmo_instance_filter_exclude;
|
||||
|
||||
};
|
||||
|
||||
@@ -107,5 +128,30 @@ namespace noggit
|
||||
QLineEdit* _filename;
|
||||
QDoubleSpinBox* _size_category_spin;
|
||||
};
|
||||
|
||||
class MinimapWMOModelFilterEntry : public QWidget
|
||||
{
|
||||
public:
|
||||
MinimapWMOModelFilterEntry(MinimapCreator* parent = nullptr);
|
||||
|
||||
QString getFileName() { return _filename->text(); };
|
||||
void setFileName(const std::string& filename) { _filename->setText(QString(filename.c_str())); };
|
||||
|
||||
private:
|
||||
QLineEdit* _filename;
|
||||
};
|
||||
|
||||
class MinimapInstanceFilterEntry : public QWidget
|
||||
{
|
||||
public:
|
||||
MinimapInstanceFilterEntry(MinimapCreator* parent = nullptr);
|
||||
|
||||
uint32_t getUid() { return _uid; };
|
||||
void setUid(uint32_t uid) { _uid = uid; _uid_label->setText(QString::fromStdString(std::to_string(uid))); };
|
||||
|
||||
private:
|
||||
uint32_t _uid;
|
||||
QLabel* _uid_label;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace noggit
|
||||
add_tool_icon (editing_mode::mccv, tr("Vertex Painter"), font_noggit::TOOL_VERTEX_PAINT);
|
||||
add_tool_icon (editing_mode::object, tr("Object Editor"), font_noggit::TOOL_OBJECT_EDITOR);
|
||||
add_tool_icon (editing_mode::minimap, tr("Minimap Editor"), font_noggit::TOOL_MINIMAP_EDITOR);
|
||||
add_tool_icon(editing_mode::stamp, tr("Stamp Mode"), font_noggit::TOOL_STAMP);
|
||||
add_tool_icon(editing_mode::stamp, tr("Stamp Mode"), font_noggit::TOOL_STAMP);
|
||||
}
|
||||
|
||||
void toolbar::add_tool_icon(editing_mode mode, const QString& name, const font_noggit::icons& icon)
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace noggit
|
||||
_color_palette->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
|
||||
layout->addRow(_color_palette);
|
||||
|
||||
auto info_label (new QLabel("drag&drop colors to select them", this));
|
||||
auto info_label (new QLabel("Drag&Drop colors to select.", this));
|
||||
info_label->setAlignment(Qt::AlignCenter);
|
||||
|
||||
layout->addRow(info_label);
|
||||
|
||||
73
src/noggit/ui/style/DarkStyle.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
###############################################################################
|
||||
# #
|
||||
# The MIT License #
|
||||
# #
|
||||
# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) #
|
||||
# >> https://github.com/Jorgen-VikingGod #
|
||||
# #
|
||||
# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle #
|
||||
# #
|
||||
###############################################################################
|
||||
*/
|
||||
|
||||
#include "DarkStyle.h"
|
||||
|
||||
DarkStyle::DarkStyle() : DarkStyle(styleBase()) {}
|
||||
|
||||
DarkStyle::DarkStyle(QStyle *style) : QProxyStyle(style) {}
|
||||
|
||||
QStyle *DarkStyle::styleBase(QStyle *style) const {
|
||||
static QStyle *base =
|
||||
!style ? QStyleFactory::create(QStringLiteral("Fusion")) : style;
|
||||
return base;
|
||||
}
|
||||
|
||||
QStyle *DarkStyle::baseStyle() const { return styleBase(); }
|
||||
|
||||
void DarkStyle::polish(QPalette &palette) {
|
||||
// modify palette to dark
|
||||
palette.setColor(QPalette::Window, QColor(53, 53, 53));
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
palette.setColor(QPalette::Disabled, QPalette::WindowText,
|
||||
QColor(127, 127, 127));
|
||||
palette.setColor(QPalette::Base, QColor(42, 42, 42));
|
||||
palette.setColor(QPalette::AlternateBase, QColor(66, 66, 66));
|
||||
palette.setColor(QPalette::ToolTipBase, Qt::white);
|
||||
palette.setColor(QPalette::ToolTipText, QColor(53, 53, 53));
|
||||
palette.setColor(QPalette::Text, Qt::white);
|
||||
palette.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
|
||||
palette.setColor(QPalette::Dark, QColor(35, 35, 35));
|
||||
palette.setColor(QPalette::Shadow, QColor(20, 20, 20));
|
||||
palette.setColor(QPalette::Button, QColor(53, 53, 53));
|
||||
palette.setColor(QPalette::ButtonText, Qt::white);
|
||||
palette.setColor(QPalette::Disabled, QPalette::ButtonText,
|
||||
QColor(127, 127, 127));
|
||||
palette.setColor(QPalette::BrightText, Qt::red);
|
||||
palette.setColor(QPalette::Link, QColor(42, 130, 218));
|
||||
palette.setColor(QPalette::Highlight, QColor(42, 130, 218));
|
||||
palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80));
|
||||
palette.setColor(QPalette::HighlightedText, Qt::white);
|
||||
palette.setColor(QPalette::Disabled, QPalette::HighlightedText,
|
||||
QColor(127, 127, 127));
|
||||
}
|
||||
|
||||
void DarkStyle::polish(QApplication *app) {
|
||||
if (!app) return;
|
||||
|
||||
// increase font size for better reading,
|
||||
// setPointSize was reduced from +2 because when applied this way in Qt5, the
|
||||
// font is larger than intended for some reason
|
||||
QFont defaultFont = QApplication::font();
|
||||
defaultFont.setPointSize(defaultFont.pointSize() + 1);
|
||||
app->setFont(defaultFont);
|
||||
|
||||
// loadstylesheet
|
||||
QFile qfDarkstyle(QStringLiteral(":/darkstyle/darkstyle.qss"));
|
||||
if (qfDarkstyle.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
// set stylesheet
|
||||
QString qsStylesheet = QString::fromLatin1(qfDarkstyle.readAll());
|
||||
app->setStyleSheet(qsStylesheet);
|
||||
qfDarkstyle.close();
|
||||
}
|
||||
}
|
||||
39
src/noggit/ui/style/DarkStyle.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
###############################################################################
|
||||
# #
|
||||
# The MIT License #
|
||||
# #
|
||||
# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) #
|
||||
# >> https://github.com/Jorgen-VikingGod #
|
||||
# #
|
||||
# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle #
|
||||
# #
|
||||
###############################################################################
|
||||
*/
|
||||
|
||||
#ifndef DARKSTYLE_HPP
|
||||
#define DARKSTYLE_HPP
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QFont>
|
||||
#include <QProxyStyle>
|
||||
#include <QStyleFactory>
|
||||
|
||||
class DarkStyle : public QProxyStyle {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DarkStyle();
|
||||
explicit DarkStyle(QStyle *style);
|
||||
|
||||
QStyle *baseStyle() const;
|
||||
|
||||
void polish(QPalette &palette) override;
|
||||
void polish(QApplication *app) override;
|
||||
|
||||
private:
|
||||
QStyle *styleBase(QStyle *style = Q_NULLPTR) const;
|
||||
};
|
||||
|
||||
#endif // DARKSTYLE_HPP
|
||||
343
src/noggit/ui/style/darkstyle/darkstyle.qss
Normal file
@@ -0,0 +1,343 @@
|
||||
QToolTip{
|
||||
color:#ffffff;
|
||||
background-color:palette(base);
|
||||
border:1px solid palette(highlight);
|
||||
border-radius:4px;
|
||||
}
|
||||
QStatusBar{
|
||||
background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
color:palette(mid);
|
||||
}
|
||||
QMenuBar{
|
||||
background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border-bottom:2px solid rgba(25,25,25,75);
|
||||
}
|
||||
QMenuBar::item{
|
||||
spacing:2px;
|
||||
padding:3px 4px;
|
||||
background:transparent;
|
||||
}
|
||||
QMenuBar::item:selected{
|
||||
background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(106,106,106,255),stop:1 rgba(106,106,106,75));
|
||||
border-left:1px solid rgba(106,106,106,127);
|
||||
border-right:1px solid rgba(106,106,106,127);
|
||||
}
|
||||
QMenuBar::item:pressed{
|
||||
background-color:palette(highlight);
|
||||
border-left:1px solid rgba(25,25,25,127);
|
||||
border-right:1px solid rgba(25,25,25,127);
|
||||
}
|
||||
QMenu{
|
||||
background-color:palette(window);
|
||||
border:1px solid palette(shadow);
|
||||
}
|
||||
QMenu::item{
|
||||
padding:3px 25px 3px 25px;
|
||||
border:1px solid transparent;
|
||||
}
|
||||
QMenu::item:disabled{
|
||||
background-color:rgba(35,35,35,127);
|
||||
color:palette(disabled);
|
||||
}
|
||||
QMenu::item:selected{
|
||||
border-color:rgba(147,191,236,127);
|
||||
background:palette(highlight);
|
||||
}
|
||||
QMenu::icon:checked{
|
||||
background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border:1px solid palette(highlight);
|
||||
border-radius:2px;
|
||||
}
|
||||
QMenu::separator{
|
||||
height:1px;
|
||||
background:palette(alternate-base);
|
||||
margin-left:5px;
|
||||
margin-right:5px;
|
||||
}
|
||||
QMenu::indicator{
|
||||
width:18px;
|
||||
height:18px;
|
||||
}
|
||||
QMenu::indicator:non-exclusive:checked{
|
||||
image:url(:/darkstyle/icon_checkbox_checked.png);
|
||||
padding-left:2px;
|
||||
}
|
||||
QMenu::indicator:non-exclusive:unchecked{
|
||||
image:url(:/darkstyle/icon_checkbox_unchecked.png);
|
||||
padding-left:2px;
|
||||
}
|
||||
QMenu::indicator:exclusive:checked{
|
||||
image:url(:/darkstyle/icon_radiobutton_checked.png);
|
||||
padding-left:2px;
|
||||
}
|
||||
QMenu::indicator:exclusive:unchecked{
|
||||
image:url(:/darkstyle/icon_radiobutton_unchecked.png);
|
||||
padding-left:2px;
|
||||
}
|
||||
QToolBar::top{
|
||||
background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border-bottom:3px solid qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
}
|
||||
QToolBar::bottom{
|
||||
background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border-top:3px solid qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
}
|
||||
QToolBar::left{
|
||||
background-color:qlineargradient(x1:0,y1:0,x2:1,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border-right:3px solid qlineargradient(x1:0,y1:0,x2:1,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
}
|
||||
QToolBar::right{
|
||||
background-color:qlineargradient(x1:1,y1:0,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border-left:3px solid qlineargradient(x1:1,y1:0,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
}
|
||||
QMainWindow::separator{
|
||||
width:6px;
|
||||
height:5px;
|
||||
padding:2px;
|
||||
}
|
||||
QSplitter::handle:horizontal{
|
||||
width:10px;
|
||||
}
|
||||
QSplitter::handle:vertical{
|
||||
height:10px;
|
||||
}
|
||||
QMainWindow::separator:hover,QSplitter::handle:hover{
|
||||
background:palette(highlight);
|
||||
}
|
||||
QDockWidget::title{
|
||||
padding:4px;
|
||||
background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border:1px solid rgba(25,25,25,75);
|
||||
border-bottom:2px solid rgba(25,25,25,75);
|
||||
}
|
||||
QDockWidget{
|
||||
titlebar-close-icon:url(:/darkstyle/icon_close.png);
|
||||
titlebar-normal-icon:url(:/darkstyle/icon_restore.png);
|
||||
}
|
||||
QDockWidget::close-button,QDockWidget::float-button{
|
||||
subcontrol-position:top right;
|
||||
subcontrol-origin:margin;
|
||||
position:absolute;
|
||||
top:3px;
|
||||
bottom:0px;
|
||||
width:20px;
|
||||
height:20px;
|
||||
}
|
||||
QDockWidget::close-button{
|
||||
right:3px;
|
||||
}
|
||||
QDockWidget::float-button{
|
||||
right:25px;
|
||||
}
|
||||
QGroupBox{
|
||||
background-color:rgba(66,66,66,50%);
|
||||
margin-top:27px;
|
||||
border:1px solid rgba(25,25,25,127);
|
||||
border-radius:4px;
|
||||
}
|
||||
QGroupBox::title{
|
||||
subcontrol-origin:margin;
|
||||
subcontrol-position:left top;
|
||||
padding:4px 6px;
|
||||
margin-left:3px;
|
||||
background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border:1px solid rgba(25,25,25,75);
|
||||
border-bottom:2px solid rgb(127,127,127);
|
||||
border-top-left-radius:4px;
|
||||
border-top-right-radius:4px;
|
||||
}
|
||||
QTabWidget::pane{
|
||||
background-color:rgba(66,66,66,50%);
|
||||
border-top:1px solid rgba(25,25,25,50%);
|
||||
}
|
||||
QTabWidget::tab-bar{
|
||||
left:3px;
|
||||
top:1px;
|
||||
}
|
||||
QTabBar{
|
||||
background-color:transparent;
|
||||
qproperty-drawBase:0;
|
||||
border-bottom:1px solid rgba(25,25,25,50%);
|
||||
}
|
||||
QTabBar::tab{
|
||||
padding:4px 6px;
|
||||
background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border:1px solid rgba(25,25,25,75);
|
||||
border-top-left-radius:4px;
|
||||
border-top-right-radius:4px;
|
||||
}
|
||||
QTabBar::tab:selected,QTabBar::tab:hover{
|
||||
background-color:qlineargradient(x1:0,y1:0,x2:0,y2:1,stop:0 rgba(53,53,53,127),stop:1 rgba(66,66,66,50%));
|
||||
border-bottom-color:rgba(66,66,66,75%);
|
||||
}
|
||||
QTabBar::tab:selected{
|
||||
border-bottom:2px solid palette(highlight);
|
||||
}
|
||||
QTabBar::tab::selected:disabled{
|
||||
border-bottom:2px solid rgb(127,127,127);
|
||||
}
|
||||
QTabBar::tab:!selected{
|
||||
margin-top:2px;
|
||||
}
|
||||
QCheckBox::indicator{
|
||||
width:18px;
|
||||
height:18px;
|
||||
}
|
||||
QCheckBox::indicator:checked,QTreeView::indicator:checked,QTableView::indicator:checked,QGroupBox::indicator:checked{
|
||||
image:url(:/darkstyle/icon_checkbox_checked.png);
|
||||
}
|
||||
QCheckBox::indicator:checked:pressed,QTreeView::indicator:checked:pressed,QTableView::indicator:checked:pressed,QGroupBox::indicator:checked:pressed{
|
||||
image:url(:/darkstyle/icon_checkbox_checked_pressed.png);
|
||||
}
|
||||
QCheckBox::indicator:checked:disabled,QTreeView::indicator:checked:disabled,QTableView::indicator:checked:disabled,QGroupBox::indicator:checked:disabled{
|
||||
image:url(:/darkstyle/icon_checkbox_checked_disabled.png);
|
||||
}
|
||||
QCheckBox::indicator:unchecked,QTreeView::indicator:unchecked,QTableView::indicator:unchecked,QGroupBox::indicator:unchecked{
|
||||
image:url(:/darkstyle/icon_checkbox_unchecked.png);
|
||||
}
|
||||
QCheckBox::indicator:unchecked:pressed,QTreeView::indicator:unchecked:pressed,QTableView::indicator:unchecked:pressed,QGroupBox::indicator:unchecked:pressed{
|
||||
image:url(:/darkstyle/icon_checkbox_unchecked_pressed.png);
|
||||
}
|
||||
QCheckBox::indicator:unchecked:disabled,QTreeView::indicator:unchecked:disabled,QTableView::indicator:unchecked:disabled,QGroupBox::indicator:unchecked:disabled{
|
||||
image:url(:/darkstyle/icon_checkbox_unchecked_disabled.png);
|
||||
}
|
||||
QCheckBox::indicator:indeterminate,QTreeView::indicator:indeterminate,QTableView::indicator:indeterminate,QGroupBox::indicator:indeterminate{
|
||||
image:url(:/darkstyle/icon_checkbox_indeterminate.png);
|
||||
}
|
||||
QCheckBox::indicator:indeterminate:pressed,QTreeView::indicator:indeterminate:pressed,QTableView::indicator:indeterminate:pressed,QGroupBox::indicator:indeterminate:pressed{
|
||||
image:url(:/darkstyle/icon_checkbox_indeterminate_pressed.png);
|
||||
}
|
||||
QCheckBox::indicator:indeterminate:disabled,QTreeView::indicator:indeterminate:disabled,QTableView::indicator:indeterminate:disabled,QGroupBox::indicator:indeterminate:disabled{
|
||||
image:url(:/darkstyle/icon_checkbox_indeterminate_disabled.png);
|
||||
}
|
||||
QRadioButton::indicator{
|
||||
width:18px;
|
||||
height:18px;
|
||||
}
|
||||
QRadioButton::indicator:checked{
|
||||
image:url(:/darkstyle/icon_radiobutton_checked.png);
|
||||
}
|
||||
QRadioButton::indicator:checked:pressed{
|
||||
image:url(:/darkstyle/icon_radiobutton_checked_pressed.png);
|
||||
}
|
||||
QRadioButton::indicator:checked:disabled{
|
||||
image:url(:/darkstyle/icon_radiobutton_checked_disabled.png);
|
||||
}
|
||||
QRadioButton::indicator:unchecked{
|
||||
image:url(:/darkstyle/icon_radiobutton_unchecked.png);
|
||||
}
|
||||
QRadioButton::indicator:unchecked:pressed{
|
||||
image:url(:/darkstyle/icon_radiobutton_unchecked_pressed.png);
|
||||
}
|
||||
QRadioButton::indicator:unchecked:disabled{
|
||||
image:url(:/darkstyle/icon_radiobutton_unchecked_disabled.png);
|
||||
}
|
||||
QTreeView, QTableView{
|
||||
alternate-background-color:palette(window);
|
||||
background:palette(base);
|
||||
}
|
||||
QTreeView QHeaderView::section, QTableView QHeaderView::section{
|
||||
background-color:qlineargradient(x1:0,y1:1,x2:0,y2:0,stop:0 rgba(25,25,25,127),stop:1 rgba(53,53,53,75));
|
||||
border-style:none;
|
||||
border-bottom:1px solid palette(dark);
|
||||
padding-left:5px;
|
||||
padding-right:5px;
|
||||
}
|
||||
QTreeView::item:selected:disabled, QTableView::item:selected:disabled{
|
||||
background:rgb(80,80,80);
|
||||
}
|
||||
QTreeView::branch{
|
||||
background-color:palette(base);
|
||||
}
|
||||
QTreeView::branch:has-siblings:!adjoins-item{
|
||||
border-image:url(:/darkstyle/icon_vline.png) 0;
|
||||
}
|
||||
QTreeView::branch:has-siblings:adjoins-item{
|
||||
border-image:url(:/darkstyle/icon_branch_more.png) 0;
|
||||
}
|
||||
QTreeView::branch:!has-children:!has-siblings:adjoins-item{
|
||||
border-image:url(:/darkstyle/icon_branch_end.png) 0;
|
||||
}
|
||||
QTreeView::branch:has-children:!has-siblings:closed,
|
||||
QTreeView::branch:closed:has-children:has-siblings{
|
||||
border-image:none;
|
||||
image:url(:/darkstyle/icon_branch_closed.png);
|
||||
}
|
||||
QTreeView::branch:open:has-children:!has-siblings,
|
||||
QTreeView::branch:open:has-children:has-siblings{
|
||||
border-image:none;
|
||||
image:url(:/darkstyle/icon_branch_open.png);
|
||||
}
|
||||
QScrollBar:vertical{
|
||||
background:palette(base);
|
||||
border-top-right-radius:2px;
|
||||
border-bottom-right-radius:2px;
|
||||
width:16px;
|
||||
margin:0px;
|
||||
}
|
||||
QScrollBar::handle:vertical{
|
||||
background-color:palette(alternate-base);
|
||||
border-radius:2px;
|
||||
min-height:20px;
|
||||
margin:2px 4px 2px 4px;
|
||||
}
|
||||
QScrollBar::handle:vertical:hover{
|
||||
background-color:palette(highlight);
|
||||
}
|
||||
QScrollBar::add-line:vertical{
|
||||
background:none;
|
||||
height:0px;
|
||||
subcontrol-position:right;
|
||||
subcontrol-origin:margin;
|
||||
}
|
||||
QScrollBar::sub-line:vertical{
|
||||
background:none;
|
||||
height:0px;
|
||||
subcontrol-position:left;
|
||||
subcontrol-origin:margin;
|
||||
}
|
||||
QScrollBar:horizontal{
|
||||
background:palette(base);
|
||||
height:16px;
|
||||
margin:0px;
|
||||
}
|
||||
QScrollBar::handle:horizontal{
|
||||
background-color:palette(alternate-base);
|
||||
border-radius:2px;
|
||||
min-width:20px;
|
||||
margin:4px 2px 4px 2px;
|
||||
}
|
||||
QScrollBar::handle:horizontal:hover{
|
||||
background-color:palette(highlight);
|
||||
}
|
||||
QScrollBar::add-line:horizontal{
|
||||
background:none;
|
||||
width:0px;
|
||||
subcontrol-position:bottom;
|
||||
subcontrol-origin:margin;
|
||||
}
|
||||
QScrollBar::sub-line:horizontal{
|
||||
background:none;
|
||||
width:0px;
|
||||
subcontrol-position:top;
|
||||
subcontrol-origin:margin;
|
||||
}
|
||||
QSlider::handle:horizontal{
|
||||
border-radius:4px;
|
||||
border:1px solid rgba(25,25,25,255);
|
||||
background-color:palette(alternate-base);
|
||||
min-height:20px;
|
||||
margin:0 -4px;
|
||||
}
|
||||
QSlider::handle:horizontal:hover{
|
||||
background:palette(highlight);
|
||||
}
|
||||
QSlider::add-page:horizontal{
|
||||
background:palette(base);
|
||||
}
|
||||
QSlider::sub-page:horizontal{
|
||||
background:palette(highlight);
|
||||
}
|
||||
QSlider::sub-page:horizontal:disabled{
|
||||
background:rgb(80,80,80);
|
||||
}
|
||||
BIN
src/noggit/ui/style/darkstyle/icon_branch_closed.png
Normal file
|
After Width: | Height: | Size: 310 B |
BIN
src/noggit/ui/style/darkstyle/icon_branch_end.png
Normal file
|
After Width: | Height: | Size: 358 B |
BIN
src/noggit/ui/style/darkstyle/icon_branch_more.png
Normal file
|
After Width: | Height: | Size: 207 B |
BIN
src/noggit/ui/style/darkstyle/icon_branch_open.png
Normal file
|
After Width: | Height: | Size: 313 B |
BIN
src/noggit/ui/style/darkstyle/icon_checkbox_checked.png
Normal file
|
After Width: | Height: | Size: 176 B |
BIN
src/noggit/ui/style/darkstyle/icon_checkbox_checked_disabled.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
src/noggit/ui/style/darkstyle/icon_checkbox_checked_pressed.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
src/noggit/ui/style/darkstyle/icon_checkbox_indeterminate.png
Normal file
|
After Width: | Height: | Size: 121 B |
|
After Width: | Height: | Size: 286 B |
|
After Width: | Height: | Size: 286 B |
BIN
src/noggit/ui/style/darkstyle/icon_checkbox_unchecked.png
Normal file
|
After Width: | Height: | Size: 119 B |
|
After Width: | Height: | Size: 238 B |
|
After Width: | Height: | Size: 238 B |
BIN
src/noggit/ui/style/darkstyle/icon_close.png
Normal file
|
After Width: | Height: | Size: 422 B |
BIN
src/noggit/ui/style/darkstyle/icon_radiobutton_checked.png
Normal file
|
After Width: | Height: | Size: 370 B |
|
After Width: | Height: | Size: 617 B |
|
After Width: | Height: | Size: 616 B |
BIN
src/noggit/ui/style/darkstyle/icon_radiobutton_unchecked.png
Normal file
|
After Width: | Height: | Size: 310 B |
|
After Width: | Height: | Size: 538 B |
|
After Width: | Height: | Size: 537 B |
BIN
src/noggit/ui/style/darkstyle/icon_restore.png
Normal file
|
After Width: | Height: | Size: 404 B |
BIN
src/noggit/ui/style/darkstyle/icon_undock.png
Normal file
|
After Width: | Height: | Size: 424 B |
BIN
src/noggit/ui/style/darkstyle/icon_vline.png
Normal file
|
After Width: | Height: | Size: 303 B |
458
src/noggit/ui/style/framelesswindow/framelesswindow.cpp
Normal file
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
###############################################################################
|
||||
# #
|
||||
# The MIT License #
|
||||
# #
|
||||
# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) #
|
||||
# >> https://github.com/Jorgen-VikingGod #
|
||||
# #
|
||||
# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle #
|
||||
# #
|
||||
###############################################################################
|
||||
*/
|
||||
|
||||
#include "framelesswindow.h"
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QScreen>
|
||||
|
||||
#include "ui_framelesswindow.h"
|
||||
|
||||
FramelessWindow::FramelessWindow(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::FramelessWindow),
|
||||
m_bMousePressed(false),
|
||||
m_bDragTop(false),
|
||||
m_bDragLeft(false),
|
||||
m_bDragRight(false),
|
||||
m_bDragBottom(false) {
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
||||
// append minimize button flag in case of windows,
|
||||
// for correct windows native handling of minimize function
|
||||
#if defined(Q_OS_WIN)
|
||||
setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint);
|
||||
#endif
|
||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->restoreButton->setVisible(false);
|
||||
|
||||
// shadow under window title text
|
||||
QGraphicsDropShadowEffect *textShadow = new QGraphicsDropShadowEffect;
|
||||
textShadow->setBlurRadius(4.0);
|
||||
textShadow->setColor(QColor(0, 0, 0));
|
||||
textShadow->setOffset(0.0);
|
||||
ui->titleText->setGraphicsEffect(textShadow);
|
||||
|
||||
// window shadow
|
||||
QGraphicsDropShadowEffect *windowShadow = new QGraphicsDropShadowEffect;
|
||||
windowShadow->setBlurRadius(9.0);
|
||||
windowShadow->setColor(palette().color(QPalette::Highlight));
|
||||
windowShadow->setOffset(0.0);
|
||||
ui->windowFrame->setGraphicsEffect(windowShadow);
|
||||
|
||||
QObject::connect(qApp, &QGuiApplication::applicationStateChanged, this,
|
||||
&FramelessWindow::on_applicationStateChanged);
|
||||
setMouseTracking(true);
|
||||
|
||||
// important to watch mouse move from all child widgets
|
||||
QApplication::instance()->installEventFilter(this);
|
||||
}
|
||||
|
||||
FramelessWindow::~FramelessWindow() { delete ui; }
|
||||
|
||||
void FramelessWindow::on_restoreButton_clicked() {
|
||||
ui->restoreButton->setVisible(false);
|
||||
|
||||
ui->maximizeButton->setVisible(true);
|
||||
setWindowState(Qt::WindowNoState);
|
||||
// on MacOS this hack makes sure the
|
||||
// background window is repaint correctly
|
||||
hide();
|
||||
show();
|
||||
}
|
||||
|
||||
void FramelessWindow::on_maximizeButton_clicked() {
|
||||
ui->restoreButton->setVisible(true);
|
||||
ui->maximizeButton->setVisible(false);
|
||||
this->setWindowState(Qt::WindowMaximized);
|
||||
this->showMaximized();
|
||||
styleWindow(true, false);
|
||||
}
|
||||
|
||||
void FramelessWindow::changeEvent(QEvent *event) {
|
||||
if (event->type() == QEvent::WindowStateChange) {
|
||||
if (windowState().testFlag(Qt::WindowNoState)) {
|
||||
ui->restoreButton->setVisible(false);
|
||||
ui->maximizeButton->setVisible(true);
|
||||
styleWindow(true, true);
|
||||
event->ignore();
|
||||
} else if (windowState().testFlag(Qt::WindowMaximized)) {
|
||||
ui->restoreButton->setVisible(true);
|
||||
ui->maximizeButton->setVisible(false);
|
||||
styleWindow(true, false);
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void FramelessWindow::setContent(QWidget *w) {
|
||||
ui->windowContent->layout()->addWidget(w);
|
||||
}
|
||||
|
||||
void FramelessWindow::setWindowTitle(const QString &text) {
|
||||
ui->titleText->setText(text);
|
||||
}
|
||||
|
||||
void FramelessWindow::setWindowIcon(const QIcon &ico) {
|
||||
ui->icon->setPixmap(ico.pixmap(16, 16));
|
||||
}
|
||||
|
||||
void FramelessWindow::styleWindow(bool bActive, bool bNoState) {
|
||||
if (bActive) {
|
||||
if (bNoState) {
|
||||
layout()->setMargin(15);
|
||||
ui->windowTitlebar->setStyleSheet(QStringLiteral(
|
||||
"#windowTitlebar{border: 0px none palette(shadow); "
|
||||
"border-top-left-radius:5px; border-top-right-radius:5px; "
|
||||
"background-color:palette(shadow); height:20px;}"));
|
||||
ui->windowFrame->setStyleSheet(QStringLiteral(
|
||||
"#windowFrame{border:1px solid palette(highlight); border-radius:5px "
|
||||
"5px 5px 5px; background-color:palette(Window);}"));
|
||||
QGraphicsEffect *oldShadow = ui->windowFrame->graphicsEffect();
|
||||
if (oldShadow) delete oldShadow;
|
||||
QGraphicsDropShadowEffect *windowShadow = new QGraphicsDropShadowEffect;
|
||||
windowShadow->setBlurRadius(9.0);
|
||||
windowShadow->setColor(palette().color(QPalette::Highlight));
|
||||
windowShadow->setOffset(0.0);
|
||||
ui->windowFrame->setGraphicsEffect(windowShadow);
|
||||
} else {
|
||||
layout()->setMargin(0);
|
||||
ui->windowTitlebar->setStyleSheet(QStringLiteral(
|
||||
"#windowTitlebar{border: 0px none palette(shadow); "
|
||||
"border-top-left-radius:0px; border-top-right-radius:0px; "
|
||||
"background-color:palette(shadow); height:20px;}"));
|
||||
ui->windowFrame->setStyleSheet(QStringLiteral(
|
||||
"#windowFrame{border:1px solid palette(dark); border-radius:0px 0px "
|
||||
"0px 0px; background-color:palette(Window);}"));
|
||||
QGraphicsEffect *oldShadow = ui->windowFrame->graphicsEffect();
|
||||
if (oldShadow) delete oldShadow;
|
||||
ui->windowFrame->setGraphicsEffect(nullptr);
|
||||
} // if (bNoState) else maximize
|
||||
} else {
|
||||
if (bNoState) {
|
||||
layout()->setMargin(15);
|
||||
ui->windowTitlebar->setStyleSheet(QStringLiteral(
|
||||
"#windowTitlebar{border: 0px none palette(shadow); "
|
||||
"border-top-left-radius:5px; border-top-right-radius:5px; "
|
||||
"background-color:palette(dark); height:20px;}"));
|
||||
ui->windowFrame->setStyleSheet(QStringLiteral(
|
||||
"#windowFrame{border:1px solid #000000; border-radius:5px 5px 5px "
|
||||
"5px; background-color:palette(Window);}"));
|
||||
QGraphicsEffect *oldShadow = ui->windowFrame->graphicsEffect();
|
||||
if (oldShadow) delete oldShadow;
|
||||
QGraphicsDropShadowEffect *windowShadow = new QGraphicsDropShadowEffect;
|
||||
windowShadow->setBlurRadius(9.0);
|
||||
windowShadow->setColor(palette().color(QPalette::Shadow));
|
||||
windowShadow->setOffset(0.0);
|
||||
ui->windowFrame->setGraphicsEffect(windowShadow);
|
||||
} else {
|
||||
layout()->setMargin(0);
|
||||
ui->windowTitlebar->setStyleSheet(QStringLiteral(
|
||||
"#titlebarWidget{border: 0px none palette(shadow); "
|
||||
"border-top-left-radius:0px; border-top-right-radius:0px; "
|
||||
"background-color:palette(dark); height:20px;}"));
|
||||
ui->windowFrame->setStyleSheet(QStringLiteral(
|
||||
"#windowFrame{border:1px solid palette(shadow); border-radius:0px "
|
||||
"0px 0px 0px; background-color:palette(Window);}"));
|
||||
QGraphicsEffect *oldShadow = ui->windowFrame->graphicsEffect();
|
||||
if (oldShadow) delete oldShadow;
|
||||
ui->windowFrame->setGraphicsEffect(nullptr);
|
||||
} // if (bNoState) { else maximize
|
||||
} // if (bActive) { else no focus
|
||||
}
|
||||
|
||||
void FramelessWindow::on_applicationStateChanged(Qt::ApplicationState state) {
|
||||
if (windowState().testFlag(Qt::WindowNoState)) {
|
||||
if (state == Qt::ApplicationActive) {
|
||||
styleWindow(true, true);
|
||||
} else {
|
||||
styleWindow(false, true);
|
||||
}
|
||||
} else if (windowState().testFlag(Qt::WindowFullScreen)) {
|
||||
if (state == Qt::ApplicationActive) {
|
||||
styleWindow(true, false);
|
||||
} else {
|
||||
styleWindow(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FramelessWindow::on_minimizeButton_clicked() {
|
||||
setWindowState(Qt::WindowMinimized);
|
||||
}
|
||||
|
||||
void FramelessWindow::on_closeButton_clicked() { close(); }
|
||||
|
||||
void FramelessWindow::on_windowTitlebar_doubleClicked() {
|
||||
if (windowState().testFlag(Qt::WindowNoState)) {
|
||||
on_maximizeButton_clicked();
|
||||
} else if (windowState().testFlag(Qt::WindowFullScreen)) {
|
||||
on_restoreButton_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void FramelessWindow::mouseDoubleClickEvent(QMouseEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
void FramelessWindow::checkBorderDragging(QMouseEvent *event) {
|
||||
if (isMaximized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPoint globalMousePos = event->globalPos();
|
||||
if (m_bMousePressed) {
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
// available geometry excludes taskbar
|
||||
QRect availGeometry = screen->availableGeometry();
|
||||
int h = availGeometry.height();
|
||||
int w = availGeometry.width();
|
||||
QList<QScreen *> screenlist = screen->virtualSiblings();
|
||||
if (screenlist.contains(screen)) {
|
||||
QSize sz = QApplication::desktop()->size();
|
||||
h = sz.height();
|
||||
w = sz.width();
|
||||
}
|
||||
|
||||
// top right corner
|
||||
if (m_bDragTop && m_bDragRight) {
|
||||
int diff =
|
||||
globalMousePos.x() - (m_StartGeometry.x() + m_StartGeometry.width());
|
||||
int neww = m_StartGeometry.width() + diff;
|
||||
diff = globalMousePos.y() - m_StartGeometry.y();
|
||||
int newy = m_StartGeometry.y() + diff;
|
||||
if (neww > 0 && newy > 0 && newy < h - 50) {
|
||||
QRect newg = m_StartGeometry;
|
||||
newg.setWidth(neww);
|
||||
newg.setX(m_StartGeometry.x());
|
||||
newg.setY(newy);
|
||||
setGeometry(newg);
|
||||
}
|
||||
}
|
||||
// top left corner
|
||||
else if (m_bDragTop && m_bDragLeft) {
|
||||
int diff = globalMousePos.y() - m_StartGeometry.y();
|
||||
int newy = m_StartGeometry.y() + diff;
|
||||
diff = globalMousePos.x() - m_StartGeometry.x();
|
||||
int newx = m_StartGeometry.x() + diff;
|
||||
if (newy > 0 && newx > 0) {
|
||||
QRect newg = m_StartGeometry;
|
||||
newg.setY(newy);
|
||||
newg.setX(newx);
|
||||
setGeometry(newg);
|
||||
}
|
||||
}
|
||||
// bottom right corner
|
||||
else if (m_bDragBottom && m_bDragLeft) {
|
||||
int diff =
|
||||
globalMousePos.y() - (m_StartGeometry.y() + m_StartGeometry.height());
|
||||
int newh = m_StartGeometry.height() + diff;
|
||||
diff = globalMousePos.x() - m_StartGeometry.x();
|
||||
int newx = m_StartGeometry.x() + diff;
|
||||
if (newh > 0 && newx > 0) {
|
||||
QRect newg = m_StartGeometry;
|
||||
newg.setX(newx);
|
||||
newg.setHeight(newh);
|
||||
setGeometry(newg);
|
||||
}
|
||||
} else if (m_bDragTop) {
|
||||
int diff = globalMousePos.y() - m_StartGeometry.y();
|
||||
int newy = m_StartGeometry.y() + diff;
|
||||
if (newy > 0 && newy < h - 50) {
|
||||
QRect newg = m_StartGeometry;
|
||||
newg.setY(newy);
|
||||
setGeometry(newg);
|
||||
}
|
||||
} else if (m_bDragLeft) {
|
||||
int diff = globalMousePos.x() - m_StartGeometry.x();
|
||||
int newx = m_StartGeometry.x() + diff;
|
||||
if (newx > 0 && newx < w - 50) {
|
||||
QRect newg = m_StartGeometry;
|
||||
newg.setX(newx);
|
||||
setGeometry(newg);
|
||||
}
|
||||
} else if (m_bDragRight) {
|
||||
int diff =
|
||||
globalMousePos.x() - (m_StartGeometry.x() + m_StartGeometry.width());
|
||||
int neww = m_StartGeometry.width() + diff;
|
||||
if (neww > 0) {
|
||||
QRect newg = m_StartGeometry;
|
||||
newg.setWidth(neww);
|
||||
newg.setX(m_StartGeometry.x());
|
||||
setGeometry(newg);
|
||||
}
|
||||
} else if (m_bDragBottom) {
|
||||
int diff =
|
||||
globalMousePos.y() - (m_StartGeometry.y() + m_StartGeometry.height());
|
||||
int newh = m_StartGeometry.height() + diff;
|
||||
if (newh > 0) {
|
||||
QRect newg = m_StartGeometry;
|
||||
newg.setHeight(newh);
|
||||
newg.setY(m_StartGeometry.y());
|
||||
setGeometry(newg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// no mouse pressed
|
||||
if (leftBorderHit(globalMousePos) && topBorderHit(globalMousePos)) {
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
} else if (rightBorderHit(globalMousePos) && topBorderHit(globalMousePos)) {
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
} else if (leftBorderHit(globalMousePos) &&
|
||||
bottomBorderHit(globalMousePos)) {
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
} else {
|
||||
if (topBorderHit(globalMousePos)) {
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
} else if (leftBorderHit(globalMousePos)) {
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
} else if (rightBorderHit(globalMousePos)) {
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
} else if (bottomBorderHit(globalMousePos)) {
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
} else {
|
||||
m_bDragTop = false;
|
||||
m_bDragLeft = false;
|
||||
m_bDragRight = false;
|
||||
m_bDragBottom = false;
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pos in global virtual desktop coordinates
|
||||
bool FramelessWindow::leftBorderHit(const QPoint &pos) {
|
||||
const QRect &rect = this->geometry();
|
||||
if (pos.x() >= rect.x() && pos.x() <= rect.x() + CONST_DRAG_BORDER_SIZE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FramelessWindow::rightBorderHit(const QPoint &pos) {
|
||||
const QRect &rect = this->geometry();
|
||||
int tmp = rect.x() + rect.width();
|
||||
if (pos.x() <= tmp && pos.x() >= (tmp - CONST_DRAG_BORDER_SIZE)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FramelessWindow::topBorderHit(const QPoint &pos) {
|
||||
const QRect &rect = this->geometry();
|
||||
if (pos.y() >= rect.y() && pos.y() <= rect.y() + CONST_DRAG_BORDER_SIZE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FramelessWindow::bottomBorderHit(const QPoint &pos) {
|
||||
const QRect &rect = this->geometry();
|
||||
int tmp = rect.y() + rect.height();
|
||||
if (pos.y() <= tmp && pos.y() >= (tmp - CONST_DRAG_BORDER_SIZE)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FramelessWindow::mousePressEvent(QMouseEvent *event) {
|
||||
if (isMaximized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_bMousePressed = true;
|
||||
m_StartGeometry = this->geometry();
|
||||
|
||||
QPoint globalMousePos = mapToGlobal(QPoint(event->x(), event->y()));
|
||||
|
||||
if (leftBorderHit(globalMousePos) && topBorderHit(globalMousePos)) {
|
||||
m_bDragTop = true;
|
||||
m_bDragLeft = true;
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
} else if (rightBorderHit(globalMousePos) && topBorderHit(globalMousePos)) {
|
||||
m_bDragRight = true;
|
||||
m_bDragTop = true;
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
} else if (leftBorderHit(globalMousePos) && bottomBorderHit(globalMousePos)) {
|
||||
m_bDragLeft = true;
|
||||
m_bDragBottom = true;
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
} else {
|
||||
if (topBorderHit(globalMousePos)) {
|
||||
m_bDragTop = true;
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
} else if (leftBorderHit(globalMousePos)) {
|
||||
m_bDragLeft = true;
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
} else if (rightBorderHit(globalMousePos)) {
|
||||
m_bDragRight = true;
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
} else if (bottomBorderHit(globalMousePos)) {
|
||||
m_bDragBottom = true;
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FramelessWindow::mouseReleaseEvent(QMouseEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
if (isMaximized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_bMousePressed = false;
|
||||
bool bSwitchBackCursorNeeded =
|
||||
m_bDragTop || m_bDragLeft || m_bDragRight || m_bDragBottom;
|
||||
m_bDragTop = false;
|
||||
m_bDragLeft = false;
|
||||
m_bDragRight = false;
|
||||
m_bDragBottom = false;
|
||||
if (bSwitchBackCursorNeeded) {
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
}
|
||||
|
||||
bool FramelessWindow::eventFilter(QObject *obj, QEvent *event) {
|
||||
if (isMaximized()) {
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
// check mouse move event when mouse is moved on any object
|
||||
if (event->type() == QEvent::MouseMove) {
|
||||
QMouseEvent *pMouse = dynamic_cast<QMouseEvent *>(event);
|
||||
if (pMouse) {
|
||||
checkBorderDragging(pMouse);
|
||||
}
|
||||
}
|
||||
// press is triggered only on frame window
|
||||
else if (event->type() == QEvent::MouseButtonPress && obj == this) {
|
||||
QMouseEvent *pMouse = dynamic_cast<QMouseEvent *>(event);
|
||||
if (pMouse) {
|
||||
mousePressEvent(pMouse);
|
||||
}
|
||||
} else if (event->type() == QEvent::MouseButtonRelease) {
|
||||
if (m_bMousePressed) {
|
||||
QMouseEvent *pMouse = dynamic_cast<QMouseEvent *>(event);
|
||||
if (pMouse) {
|
||||
mouseReleaseEvent(pMouse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
69
src/noggit/ui/style/framelesswindow/framelesswindow.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
###############################################################################
|
||||
# #
|
||||
# The MIT License #
|
||||
# #
|
||||
# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) #
|
||||
# >> https://github.com/Jorgen-VikingGod #
|
||||
# #
|
||||
# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle #
|
||||
# #
|
||||
###############################################################################
|
||||
*/
|
||||
|
||||
#ifndef FRAMELESSWINDOW_H
|
||||
#define FRAMELESSWINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class FramelessWindow;
|
||||
}
|
||||
|
||||
class FramelessWindow : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FramelessWindow(QWidget *parent = Q_NULLPTR);
|
||||
virtual ~FramelessWindow();
|
||||
void setContent(QWidget *w);
|
||||
|
||||
private:
|
||||
bool leftBorderHit(const QPoint &pos);
|
||||
bool rightBorderHit(const QPoint &pos);
|
||||
bool topBorderHit(const QPoint &pos);
|
||||
bool bottomBorderHit(const QPoint &pos);
|
||||
void styleWindow(bool bActive, bool bNoState);
|
||||
|
||||
public slots:
|
||||
void setWindowTitle(const QString &text);
|
||||
void setWindowIcon(const QIcon &ico);
|
||||
|
||||
private slots:
|
||||
void on_applicationStateChanged(Qt::ApplicationState state);
|
||||
void on_minimizeButton_clicked();
|
||||
void on_restoreButton_clicked();
|
||||
void on_maximizeButton_clicked();
|
||||
void on_closeButton_clicked();
|
||||
void on_windowTitlebar_doubleClicked();
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *event);
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
virtual void checkBorderDragging(QMouseEvent *event);
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event);
|
||||
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
private:
|
||||
Ui::FramelessWindow *ui;
|
||||
QRect m_StartGeometry;
|
||||
const quint8 CONST_DRAG_BORDER_SIZE = 15;
|
||||
bool m_bMousePressed;
|
||||
bool m_bDragTop;
|
||||
bool m_bDragLeft;
|
||||
bool m_bDragRight;
|
||||
bool m_bDragBottom;
|
||||
};
|
||||
|
||||
#endif // FRAMELESSWINDOW_H
|
||||
304
src/noggit/ui/style/framelesswindow/framelesswindow.ui
Normal file
@@ -0,0 +1,304 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FramelessWindow</class>
|
||||
<widget class="QWidget" name="FramelessWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>560</width>
|
||||
<height>398</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="windowFrame" native="true">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#windowFrame{border:1px solid palette(highlight); border-radius:5px 5px 5px 5px; background-color:palette(Window);}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="WindowDragger" name="windowTitlebar" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#windowTitlebar{border: 0px none palette(base); border-top-left-radius:5px; border-top-right-radius:5px; background-color:palette(shadow); height:20px;}</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,1,0,0,0,0">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="spacer">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>4</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>4</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="icon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::NoContextMenu</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#icon {background-color:palette(shadow);}</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="titleText">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"> padding-left:5px;
|
||||
color:rgb(153,153,153);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Frameless Window (Dark Style)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="minimizeButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#minimizeButton{
|
||||
background-color:none;
|
||||
border:none;
|
||||
width:16px;
|
||||
height:16px;
|
||||
padding:4px;
|
||||
image:url(:/images/icon_window_minimize.png);
|
||||
}
|
||||
#minimizeButton:hover{
|
||||
background-color:palette(alternate-base);
|
||||
}
|
||||
#minimizeButton:pressed{
|
||||
background-color:palette(highlight);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="restoreButton">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#restoreButton{
|
||||
background-color:none;
|
||||
border:none;
|
||||
width:16px;
|
||||
height:16px;
|
||||
padding:4px;
|
||||
image:url(:/images/icon_window_restore.png);
|
||||
}
|
||||
#restoreButton:hover{
|
||||
background-color:palette(alternate-base);
|
||||
}
|
||||
#restoreButton:pressed{
|
||||
background-color:palette(highlight);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="maximizeButton">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#maximizeButton{
|
||||
background-color:none;
|
||||
border:none;
|
||||
width:16px;
|
||||
height:16px;
|
||||
padding:4px;
|
||||
image:url(:/images/icon_window_maximize.png);
|
||||
}
|
||||
#maximizeButton:hover{
|
||||
background-color:palette(alternate-base);
|
||||
}
|
||||
##maximizeButton:pressed{
|
||||
background-color:palette(highlight);
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="closeButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#closeButton{
|
||||
background-color:none;
|
||||
border:none;
|
||||
width:16px;
|
||||
height:16px;
|
||||
padding:4px;
|
||||
image:url(:/images/icon_window_close.png);
|
||||
border-top-right-radius: 5px;
|
||||
}
|
||||
#closeButton:hover{
|
||||
background-color:palette(alternate-base);
|
||||
}
|
||||
##closeButton:pressed{
|
||||
background-color:palette(highlight);
|
||||
}</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="windowContent" native="true">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">#windowContent{
|
||||
border: 0px none palette(base);
|
||||
border-radius:0px 0px 5px 5px;
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>WindowDragger</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>windowdragger.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
56
src/noggit/ui/style/framelesswindow/windowdragger.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
###############################################################################
|
||||
# #
|
||||
# The MIT License #
|
||||
# #
|
||||
# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) #
|
||||
# >> https://github.com/Jorgen-VikingGod #
|
||||
# #
|
||||
# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle #
|
||||
# #
|
||||
###############################################################################
|
||||
*/
|
||||
|
||||
#include "windowdragger.h"
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
WindowDragger::WindowDragger(QWidget *parent) : QWidget(parent) {
|
||||
mousePressed = false;
|
||||
}
|
||||
|
||||
void WindowDragger::mousePressEvent(QMouseEvent *event) {
|
||||
mousePressed = true;
|
||||
mousePos = event->globalPos();
|
||||
|
||||
QWidget *parent = parentWidget();
|
||||
if (parent) parent = parent->parentWidget();
|
||||
|
||||
if (parent) wndPos = parent->pos();
|
||||
}
|
||||
|
||||
void WindowDragger::mouseMoveEvent(QMouseEvent *event) {
|
||||
QWidget *parent = parentWidget();
|
||||
if (parent) parent = parent->parentWidget();
|
||||
|
||||
if (parent && mousePressed)
|
||||
parent->move(wndPos + (event->globalPos() - mousePos));
|
||||
}
|
||||
|
||||
void WindowDragger::mouseReleaseEvent(QMouseEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
mousePressed = false;
|
||||
}
|
||||
|
||||
void WindowDragger::paintEvent(QPaintEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
QStyleOption styleOption;
|
||||
styleOption.init(this);
|
||||
QPainter painter(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &styleOption, &painter, this);
|
||||
}
|
||||
|
||||
void WindowDragger::mouseDoubleClickEvent(QMouseEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
emit doubleClicked();
|
||||
}
|
||||
43
src/noggit/ui/style/framelesswindow/windowdragger.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
###############################################################################
|
||||
# #
|
||||
# The MIT License #
|
||||
# #
|
||||
# Copyright (C) 2017 by Juergen Skrotzky (JorgenVikingGod@gmail.com) #
|
||||
# >> https://github.com/Jorgen-VikingGod #
|
||||
# #
|
||||
# Sources: https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle #
|
||||
# #
|
||||
###############################################################################
|
||||
*/
|
||||
|
||||
#ifndef WINDOWDRAGGER_H
|
||||
#define WINDOWDRAGGER_H
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QWidget>
|
||||
|
||||
class WindowDragger : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WindowDragger(QWidget *parent = Q_NULLPTR);
|
||||
virtual ~WindowDragger() {}
|
||||
|
||||
signals:
|
||||
void doubleClicked();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
protected:
|
||||
QPoint mousePos;
|
||||
QPoint wndPos;
|
||||
bool mousePressed;
|
||||
};
|
||||
|
||||
#endif // WINDOWDRAGGER_H
|
||||
BIN
src/noggit/ui/style/images/icon_window_close.png
Normal file
|
After Width: | Height: | Size: 422 B |
BIN
src/noggit/ui/style/images/icon_window_maximize.png
Normal file
|
After Width: | Height: | Size: 386 B |
BIN
src/noggit/ui/style/images/icon_window_minimize.png
Normal file
|
After Width: | Height: | Size: 364 B |
BIN
src/noggit/ui/style/images/icon_window_restore.png
Normal file
|
After Width: | Height: | Size: 404 B |