pax_global_header00006660000000000000000000000064132543534310014515gustar00rootroot0000000000000052 comment=dfdc35a9d6eee970031cca69b38393e73472a7c2 dtkwidget-2.0.7.2/000077500000000000000000000000001325435343100136515ustar00rootroot00000000000000dtkwidget-2.0.7.2/.clog.toml000066400000000000000000000001621325435343100155470ustar00rootroot00000000000000[clog] repository = "https://github.com/linuxdeepin/dtkwidget" from-latest-tag = true changelog = "CHANGELOG.md" dtkwidget-2.0.7.2/.gitignore000066400000000000000000000004311325435343100156370ustar00rootroot00000000000000# Compiled Object files *.slo *.lo *.o # Compiled Dynamic libraries *.so *.dylib # Compiled Static libraries *.lai *.la *.a build*/ *.pro.user* *.DS_Store # executeable files *.qm src/DtkWidgets src/dtkwidget_config.h cmake/DtkWidget/DtkWidgetConfig.cmake src/qt_lib_dtk*.pri dtkwidget-2.0.7.2/.tx/000077500000000000000000000000001325435343100143625ustar00rootroot00000000000000dtkwidget-2.0.7.2/.tx/config000066400000000000000000000003321325435343100155500ustar00rootroot00000000000000[main] host = https://www.transifex.com minimum_perc = 80 mode = developer [deepin-tool-kit.dwidget] file_filter = translations/dtkwidget2_.ts source_file = translations/dtkwidget2.ts source_lang = en type = QT dtkwidget-2.0.7.2/CHANGELOG.md000066400000000000000000000452661325435343100154770ustar00rootroot00000000000000 ## 2.0.7.2 (2018-03-21) #### Bug Fixes * add DAbstractDialog::move(int, int) and DAbstractDialog::setGeometry(int, int, int, int) ([dbc0eadf](https://github.com/linuxdeepin/dtkwidget/commit/dbc0eadf427be2f3bd950e5481469616cc07b24c)) * move the DAbstractDialog window is invalid ([a04e438b](https://github.com/linuxdeepin/dtkwidget/commit/a04e438bdf4b096c95e59bf1f76d8b7bc6104612)) * can not auto adjust dialog position ([f53579c6](https://github.com/linuxdeepin/dtkwidget/commit/f53579c6f50397afed4fd8787d4a794facab85c7)) * wait dbus call return ([1cf4d0c1](https://github.com/linuxdeepin/dtkwidget/commit/1cf4d0c139d3c57212a3a7f7b8b86cd0fac177aa)) * build failed ([8afa3123](https://github.com/linuxdeepin/dtkwidget/commit/8afa31239a8f2307656a5ea6cc2c1b11fd4cf5da)) ## 2.0.7 (2018-03-06) #### Features * control single instance by env ([9c388818](https://github.com/linuxdeepin/dtkwidget/commit/9c3888182db247ad9b65448451ddbe6ad36a1741)) * support hide group ([20c72e80](https://github.com/linuxdeepin/dtkwidget/commit/20c72e805c06b2d815632a402d37cfa60f582ad4)) * add DFileDialog ([425d82bf](https://github.com/linuxdeepin/dtkwidget/commit/425d82bf52d81f4ae1f51f56c0ee5f720d0a9c84)) * dynamic website info in about dialog ([22611379](https://github.com/linuxdeepin/dtkwidget/commit/2261137990966b95ef1696410637c586350e2398)) * create cmake file by dtk_cmake ([ae5a226d](https://github.com/linuxdeepin/dtkwidget/commit/ae5a226d82933dd43ad04adcdbd6b9d973b1c189)) * support qt module ([1525c2cb](https://github.com/linuxdeepin/dtkwidget/commit/1525c2cb363ba6c963ca6d43b0ba3dc6e80ff4b0)) * update password edit style ([45f07ab6](https://github.com/linuxdeepin/dtkwidget/commit/45f07ab60d618b94ede3451063c27c6cb97e99cb)) * auto scroll when move/drag tab ([d3a266bc](https://github.com/linuxdeepin/dtkwidget/commit/d3a266bc9b871371973a969cc3d314d1daa6cb3c)) * support new and legacy dman interface ([3e3c8849](https://github.com/linuxdeepin/dtkwidget/commit/3e3c88497be7372e582ba62eadfdb3553b2449ad)) * support set combobox data with QMap ([bdad10fc](https://github.com/linuxdeepin/dtkwidget/commit/bdad10fcfc9b350bf28f4eee90233145fa4060af)) * fixed the QPrintDialog theme to dlight ([18df8e0e](https://github.com/linuxdeepin/dtkwidget/commit/18df8e0e6281ac74fb1de057ed33f3ad976ffa0b)) * support dynamic property ([b121081c](https://github.com/linuxdeepin/dtkwidget/commit/b121081cf41ee0cc6c6efe47af31c8d73f2fdcd5)) * fixed the width of the DTabBar add button to 48 ([ec322589](https://github.com/linuxdeepin/dtkwidget/commit/ec322589e3ea29ef90177e9c0af453b72413f1a4)) * add buildDtkVersion/runtimeDtkVersion to DApplication ([9aaa1583](https://github.com/linuxdeepin/dtkwidget/commit/9aaa15830c3077c48019c321a29a8f79f93c97fd)) * parser correctly when version has '.is.' ([5f48b1f9](https://github.com/linuxdeepin/dtkwidget/commit/5f48b1f9b844679854f4fd437dca300c41ef23fe)) * follow parent/toplevelWidget flags ([d1f7bad0](https://github.com/linuxdeepin/dtkwidget/commit/d1f7bad0273287782a70dc4af4cac2223133dd7d)) * support configurable whether to redefine the window content when dxcb is turned on ([1cdf42f1](https://github.com/linuxdeepin/dtkwidget/commit/1cdf42f1e8fc09b3fe67d276db69e47934359c05)) * add "target" argument for DTabBar::tabDroped ([bcd009af](https://github.com/linuxdeepin/dtkwidget/commit/bcd009afb5661de15ecb4edbde2319339e221b61)) * auto hide title when fullscreen ([3e2e2921](https://github.com/linuxdeepin/dtkwidget/commit/3e2e2921d8c22c9feee7171c11e22551bcb668d5)) * add propertys maskColor and flashColor of DTabBar ([7dd2e8b4](https://github.com/linuxdeepin/dtkwidget/commit/7dd2e8b4cee7b6fe16e3ccb2bb12d9cff65f2a2b)) * support drag tab to other for DTabBar ([f6749472](https://github.com/linuxdeepin/dtkwidget/commit/f674947255ad0d0158ec3cd8d5dd9f6927bad787)) * add DToast ([c4d3f48f](https://github.com/linuxdeepin/dtkwidget/commit/c4d3f48fba40df0b8b31932e926b767b44ace6bd)) * add window title ([e7cffb03](https://github.com/linuxdeepin/dtkwidget/commit/e7cffb03466ab45562db4afad42422b62cad557c)) * not set AA_DontCreateNativeWidgetSiblings if dxcb version greater then 1.1.5 ([5b3b4b5e](https://github.com/linuxdeepin/dtkwidget/commit/5b3b4b5eab4c96d46b444035e81124f14307b98b)) * set version form changelog ([416f2e64](https://github.com/linuxdeepin/dtkwidget/commit/416f2e64a42249ad8476a9ee2416b9fd07f2ea73)) * add property "realWindowId" for DPlatformWindowHandle ([b888a855](https://github.com/linuxdeepin/dtkwidget/commit/b888a8551f1a607e1f72b8e17b1229a17629857b)) * **DApplication:** add the property of the menu ([ff9a89d7](https://github.com/linuxdeepin/dtkwidget/commit/ff9a89d7536b2225ea341c90f3aefa2bf3b40aeb)) * **DSuggestButton:** add initialize text parameter. ([20767937](https://github.com/linuxdeepin/dtkwidget/commit/207679379da96fb52d4567dd4731a8f645c0dd81)) #### Bug Fixes * hide max button if cannot resize ([40e80880](https://github.com/linuxdeepin/dtkwidget/commit/40e80880201e3f385d34cb7f07dd69a9a6ad6cda)) * work around DSimpleListView cannot use tr ([4996efd4](https://github.com/linuxdeepin/dtkwidget/commit/4996efd4b03075efed20953a0dd4ff929c94eac3)) * dtk_build add error marco ([b1ebee2e](https://github.com/linuxdeepin/dtkwidget/commit/b1ebee2e709061942a99050093a9ebfc1e9b315a)) * use fix class name as theme file first ([fd1d76b4](https://github.com/linuxdeepin/dtkwidget/commit/fd1d76b488475e98b79ae1a1365cc724ac84739b)) * check libdframeworkdbus when build ([39aa02b1](https://github.com/linuxdeepin/dtkwidget/commit/39aa02b1450f12f52d69eb3fe38a4e4865fdfac2)) * call deepin-manual with dbus and application name ([3e4293d1](https://github.com/linuxdeepin/dtkwidget/commit/3e4293d156f29a8d192d82c8cd88a99d21f68858)) * the DPasswordEdit style is wrong at the DInputDialog ([2e1c126e](https://github.com/linuxdeepin/dtkwidget/commit/2e1c126e15d6bf12ec4aaac27494cc2a68b5b73b)) * use applycation name as new deepin-manual id ([dfb05cae](https://github.com/linuxdeepin/dtkwidget/commit/dfb05caee4ca327dc3443833965ed4614cf42a06)) * parse key with + error ([dcf3a11a](https://github.com/linuxdeepin/dtkwidget/commit/dcf3a11a3c21142c34bf934736e8637a713b33d1)) * state change not connect ([0049a065](https://github.com/linuxdeepin/dtkwidget/commit/0049a0650ee12fec6f026bdd69b2814ebda30546)) * add qt internal_module failed ([975e36df](https://github.com/linuxdeepin/dtkwidget/commit/975e36df9557c6e2e2bbf77c614c99f42eeccdd9)) * delay connect native state change signal ([48e23bc9](https://github.com/linuxdeepin/dtkwidget/commit/48e23bc9e21b6760522e362d390c98772dc549fd)) * missing window state change in event filter ([7c7a4e38](https://github.com/linuxdeepin/dtkwidget/commit/7c7a4e383e319604b0ca6ca62729756619e74105)) * DTabBar tab list automatically scrolling too slow ([199c13b1](https://github.com/linuxdeepin/dtkwidget/commit/199c13b1ac52625efad1d64d75107627c34d8d7b)) * max button hint error ([43de05f3](https://github.com/linuxdeepin/dtkwidget/commit/43de05f3d7ead7f01f0b80e18ecb2f9e19eebf14)) * do not flow windowFlags if not dxcb ([4fd67cb2](https://github.com/linuxdeepin/dtkwidget/commit/4fd67cb2bd484f505e9c92a96d1a16fd1c10e81d)) * not draw tear indicator for DTabBar ([b59cbffc](https://github.com/linuxdeepin/dtkwidget/commit/b59cbffcfa6cc237712761cb09a3ce269d832102)) * connect widgetThemeChanged ([6c2d397a](https://github.com/linuxdeepin/dtkwidget/commit/6c2d397a1a27991d5753d2575d74161db5cbf0b5)) * typo for DTabBar::createMimeDataFramTab ([4bb6f1e3](https://github.com/linuxdeepin/dtkwidget/commit/4bb6f1e32f82014c611ab256180ca485dd7d114d)) * remove border style workaround ([3030f496](https://github.com/linuxdeepin/dtkwidget/commit/3030f4966267fb9f0a6745a27decc8c6b3066323)) * hide toast label by default ([0dfb1566](https://github.com/linuxdeepin/dtkwidget/commit/0dfb15665ce2cc286015e3705e8acb38e750f7cf)) * parse config.pri failed ([a9b33216](https://github.com/linuxdeepin/dtkwidget/commit/a9b33216d3298866c9aa81bc9100bfadd38dee16)) * tabbar tab can drag only at the first time ([07cd7dac](https://github.com/linuxdeepin/dtkwidget/commit/07cd7dacf675f3e328c4e53750d727a70ee2bc0e)) * the widget's theme is not updated after changing parent ([3cb8f27a](https://github.com/linuxdeepin/dtkwidget/commit/3cb8f27adcca146d98b47f1ed7ca21439e221af0)) * can not be fixed widget style ([5bf22c11](https://github.com/linuxdeepin/dtkwidget/commit/5bf22c1117f99d5d1b08f90bd3123526fb80f5de)) * VER_MAJ/VER_MIN/VER_PAT variables is empty in qmake ([85314de3](https://github.com/linuxdeepin/dtkwidget/commit/85314de363b316afe726b5a4e96b65ce8bd5ddf7)) * VER_MAJ/VER_MIN/VER_PAT variables is empty in qmake ([13023a33](https://github.com/linuxdeepin/dtkwidget/commit/13023a33f0e71cb025aa08b4bd793cf9d05dcdff)) * set AA_DontCreateNativeWidgetSiblings to true of QGuiApplication at enable dxcb for window ([779d620b](https://github.com/linuxdeepin/dtkwidget/commit/779d620b641e0dd6da426b65f25f150187f5641f)) * include path(DTK_INCLUDEPATH) ([b6ecfd8d](https://github.com/linuxdeepin/dtkwidget/commit/b6ecfd8d78e7640b342022dfb3c75ea60a944bc5)) * **dsimplelistview:** * painting item is incomplete. ([a268fab4](https://github.com/linuxdeepin/dtkwidget/commit/a268fab4f210246f1483dcc2c0f902059e457edc)) * adjust render offset. ([a2452c1b](https://github.com/linuxdeepin/dtkwidget/commit/a2452c1bf59b7e25d0f97cd071cd2a262e89c151)) * adjust offsetY after removeing item. ([1b3b5f4a](https://github.com/linuxdeepin/dtkwidget/commit/1b3b5f4ac37ab3c885a1267965d8b11514da5308)) ## 2.0.6 (2018-01-15) #### Bug Fixes * blur effect widget not set WA_TranslucentBackground ([572ca1fc](https://github.com/linuxdeepin/dtkwidget/commit/572ca1fcb6cba67fe85e8f10fd69e32107a98c04)) * connect signals for DTabBar ([44057f46](https://github.com/linuxdeepin/dtkwidget/commit/44057f462860ce11cdb58477c083ab26cc37410d)) * blur area not scale on not use dxcb window ([d990cdf6](https://github.com/linuxdeepin/dtkwidget/commit/d990cdf66f3bf62315c14265d4e7989d332eb7b9)) * memory leak in DPictureSequenceView ([4693754f](https://github.com/linuxdeepin/dtkwidget/commit/4693754f5cf3702cb58c26d87a73402294238468)) * **DDialog:** reset DLineEdit theme error ([bc6b8f33](https://github.com/linuxdeepin/dtkwidget/commit/bc6b8f33d8cfe300d21ea03b95dedeeecc610803)) #### Features * support new dman interface ([a3e46a46](https://github.com/linuxdeepin/dtkwidget/commit/a3e46a46d6f7454a6100149e9880b614202dca83)) * add DSuggestButton and DStyleOption ([929f2154](https://github.com/linuxdeepin/dtkwidget/commit/929f2154808d4b926200daadcc5f7a5d20225e10)) * not fixed font size of DDialog ([0eb76154](https://github.com/linuxdeepin/dtkwidget/commit/0eb761540d3c8581f33aa2a67abaeee95f2812e0)) * DTabBar add scroll buttons ([2f44cd29](https://github.com/linuxdeepin/dtkwidget/commit/2f44cd29ed46e3139ff0f02e3095f0249579ee47)) * add the "dtkwidget_global.h" header file ([de47120c](https://github.com/linuxdeepin/dtkwidget/commit/de47120c6c93acfc3462d1dc52debb5310537381)) * add the "DtkWidgets" header file ([b223577e](https://github.com/linuxdeepin/dtkwidget/commit/b223577e78789d7b6ab21dea8a4596ab95c9a55c)) * add animation for DTabBar on drag move tabs ([ec3f6272](https://github.com/linuxdeepin/dtkwidget/commit/ec3f6272d5f2f16297c4d48adb1d92e415d0eda4)) * support dual-click to make crumb ([b3eaa0e8](https://github.com/linuxdeepin/dtkwidget/commit/b3eaa0e85a7b9171dccdac074dfc94ba7560ad7c)) * add the DTabBar widget ([82a45b61](https://github.com/linuxdeepin/dtkwidget/commit/82a45b6130ad98699d3dc424210611d9fdae0751)) ## 2.0.5.3 (2017-12-27) #### Bug Fixes * double click shortcutedit not sync data ([70336737](https://github.com/linuxdeepin/dtkwidget/commit/70336737ff2759245c7f1b49de6fa18b97884d9a)) * Adapt lintian ([2709dc6d](https://github.com/linuxdeepin/dtkwidget/commit/2709dc6d574e74ae4ec1d225d77a6a221534e25e)) * test correct hint for corresponding function ([8d250da3](https://github.com/linuxdeepin/dtkwidget/commit/8d250da39870332200fe0d3949c776e225f37c13)) * margin of window mode ([982940f2](https://github.com/linuxdeepin/dtkwidget/commit/982940f26b911599acb8998f862d1043cbe6335a)) * add build depend libudev-dev ([3ddffd8b](https://github.com/linuxdeepin/dtkwidget/commit/3ddffd8b5a30c262f006893965921036639d0407)) #### Features * add nameFilters to dfilechooseredit ([367d8431](https://github.com/linuxdeepin/dtkwidget/commit/367d84310a42bc71273c59b6525125d5abccff26)) * support get buildVersion form marco ([632228d2](https://github.com/linuxdeepin/dtkwidget/commit/632228d25b6b9e5ee0bb365f18a71b54ef7576c6)) * add hideAlertMessage to dlineedit ([87aff6ee](https://github.com/linuxdeepin/dtkwidget/commit/87aff6eedfa1f13d0cc15ad0836ef04d8dff1b36)) * add setFileMode/fileMode to dfilechooseredit ([770c8a83](https://github.com/linuxdeepin/dtkwidget/commit/770c8a831583f84a52db7c66910a2fdf572eddd9)) * support copy/paste for DCrumbEdit ([90a7388d](https://github.com/linuxdeepin/dtkwidget/commit/90a7388dae8c6510b8dd47d9dd5a35ba68187197)) * add widget "DCrumbEdit" ([04e21733](https://github.com/linuxdeepin/dtkwidget/commit/04e21733b77096b2b07126722f766ef38cfe28cd)) * add namaspace to DSpinner ([454c394d](https://github.com/linuxdeepin/dtkwidget/commit/454c394dc84f17e19e759a5bbcec73e1669fae5b)) * add DSpinner ([ad30eabe](https://github.com/linuxdeepin/dtkwidget/commit/ad30eabe456f2e42229dd73bfda25325fef2e557)) * add pixmap sequence interface to DPictureSequenceView ([6b568687](https://github.com/linuxdeepin/dtkwidget/commit/6b5686879f35dc038cb5a0b578d5e3267ede8976)) * add widget mode to darrowrectangle ([e500b48f](https://github.com/linuxdeepin/dtkwidget/commit/e500b48f6984dff5bff9c12e6bd0ecf467a06804)) * **DApplication:** add multi user single Instance parameter ([d35b96e5](https://github.com/linuxdeepin/dtkwidget/commit/d35b96e5a750233a73140e22833d619ae389386a)) * **DRegion:** add compatibility macro ([49db18a7](https://github.com/linuxdeepin/dtkwidget/commit/49db18a7b299fc029ba83c4882e1f3148879c47c)) ## 2.0.5.2 (2017-11-28) #### Features * add bordless window on mac ([5f47b896](https://github.com/linuxdeepin/dtkwidget/commit/5f47b89671cdf84133eed6c908cb06d66a8cc2ff)) * support DTK_TITLE_DRAG_WINDOW on mac ([20782b55](https://github.com/linuxdeepin/dtkwidget/commit/20782b5502b0452bc17f15b4736043d53d42a878)) * use D_DECL_DEPRECATED ([fe75e70f](https://github.com/linuxdeepin/dtkwidget/commit/fe75e70ffa45865a969cc3c6cb7adc033f52bb0f)) * add DFileChooserEdit light theme ([0c77c6f9](https://github.com/linuxdeepin/dtkwidget/commit/0c77c6f99a432cac949391042551a8a54dec23f3)) * show system menu on right mouse button press of DTitlebar ([52ccd1e9](https://github.com/linuxdeepin/dtkwidget/commit/52ccd1e9fb81a7fd71081411c2d1428a303d0535)) #### Bug Fixes * window motif hints is error of DMainWindow ([8f90556f](https://github.com/linuxdeepin/dtkwidget/commit/8f90556f6a8380f977f09a8bedc95a5cdd7ae760)) * fix macos build failed ([63ee2247](https://github.com/linuxdeepin/dtkwidget/commit/63ee2247367ed2fca109beda82530e2a9242e921)) * popup system menu in window content ([c481eec6](https://github.com/linuxdeepin/dtkwidget/commit/c481eec63da02acaf77d7847e403f0e5f5028688)) * correct typos in multiple files ([be8ea417](https://github.com/linuxdeepin/dtkwidget/commit/be8ea417b337a2b2c34a3523c3b73b5627d18e71)) * windows build failed ([4dd39533](https://github.com/linuxdeepin/dtkwidget/commit/4dd3953353c1ce32145e9b3da5e89e7603099d03)) ## 2.0.5.1 (2017-11-16) #### Bug Fixes * add DTK_DMAN_PORTAL support ([3c03ee65](3c03ee65)) * change the QGuiApplication::platformName() to "xcb" on dxcb platform ([4356268d](4356268d)) * isDXcbPlatform for new version dxcb plugin ([d8b5c040](d8b5c040)) * **DRegionMonitor:** * properly handle scale ([95766b45](95766b45)) * possible double freed object ([708a5fbe](708a5fbe)) #### Features * add shortcut to DMainWindow ([5e9d5b6c](5e9d5b6c)) * add F1 shortcut ([7e311564](7e311564)) * add setState to DImageButton ([fcf9c3ef](fcf9c3ef)) ## 2.0.5 (2017-11-06) #### Features * optimize shift up/down keypress for DSimpleListView ([7019967f](7019967f)) * DTitlebar add disable API ([ea92fae9](ea92fae9)) * add embed mode ([266f4337](266f4337)) * add trash dbus interface ([b88efbb8](b88efbb8)) * change productIcon to QIcon ([2a914b51](2a914b51)) * Add DHiDPIHelper class ([0fdbcf60](0fdbcf60)) * daboutdialog deepin logo support hidpi ([405352f0](405352f0)) * Set AA_UseHighDpiPixmaps on DApplication ([e9fb9fcf](e9fb9fcf)) * add svgc ([fedb3860](fedb3860)) * lineedit support hidpi ([026ecb65](026ecb65)) * titlebar buttons support hidpi ([56b11074](56b11074)) * titlebar support hidpi ([dd537c17](dd537c17)) * add dbus singleton ([6ae2978f](6ae2978f)) * dpicturesequenceview support @2x files ([a299ef09](a299ef09)) * dvideowidget support set device ratio ([74eaa1d6](74eaa1d6)) * add DWaterProgress::setTextVisible ([a61d2e88](a61d2e88)) * add DSettingsWidgetFactory ([f14ff92f](f14ff92f)) * add radius set interface to pageindicator ([7bc360c0](7bc360c0)) * add border and shadow to DWaterProgress ([ecc4ba17](ecc4ba17)) * **hidpi:** * DWaterProgress support hidpi ([94350b7f](94350b7f)) * DArrowRectangle support hidpi ([d7d6a876](d7d6a876)) #### Bug Fixes * windows build failed ([1b40d6a7](1b40d6a7)) * disable _q_onTopWindowMotifHintsChanged when use DTitlebar::setWindowFlags ([5e0149b5](5e0149b5)) * draw pixmap size error on DTitlebar ([228fd523](228fd523)) * DTitlebar button is hidden on the non DMainWindow windows ([7b131a72](7b131a72)) * paint DBlurEffectWindow error if device pixel ratio is not 1 ([dff92b1b](dff92b1b)) * min/maximize button is hidden on DMainWindow ([89279ac4](89279ac4)) * fix hidpi load icon size ([79e81f94](79e81f94)) * update DDialog message style ([2c6133c1](2c6133c1)) * crash on multiple apps registered xmouseare ([dea8651f](dea8651f)) * icon of DSearchEdit not clear on hidpi ([6ebada94](6ebada94)) * DSimpleListview arrow isn't visible ([b08e7f1c](b08e7f1c)) * DAboutDialog icon not supporting hidpi ([6ec60734](6ec60734)) * fix dtk-svgc crash if no font init ([83857265](83857265)) * fix settings dialog style ([797c3e35](797c3e35)) * dialog use same style as light ([9d7d4a61](9d7d4a61)) * fix windows build failed ([7f31ea48](7f31ea48)) * fix dialog size error on hidpi ([b9273c72](b9273c72)) * update translation ([0045c39e](0045c39e)) * crash if setIcon with svg ([9b577be3](9b577be3)) * remove useless image ([10c9607c](10c9607c)) * remove private header file ([61b375b2](61b375b2)) * dswitchbutton error calculation radius ([d742b169](d742b169)) * dimagebutton private not initialized ([146d893e](146d893e)) * **DArrowRectangle:** arrow position error ([592187fb](592187fb)) * **DPasswordEdit:** password edit icon out of content ([c1fe173a](c1fe173a)) dtkwidget-2.0.7.2/LICENSE000066400000000000000000001045141325435343100146630ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . dtkwidget-2.0.7.2/README.md000066400000000000000000000020361325435343100151310ustar00rootroot00000000000000# Deepin Tool Kit Widget {#mainpage} Deepint Tool Kit (Dtk) is the base devlopment tool of all C++/Qt Developer work on Deepin. ## Dependencies ### Build dependencies * Qt >= 5.6 ## Installation ### Build from source code 1. Make sure you have installed all dependencies. 2. Build: ```` $ mkdir build $ cd build $ qmake .. $ make ```` 3. Install: ```` $ sudo make install ```` ## Getting help Any usage issues can ask for help via * [Gitter](https://gitter.im/orgs/linuxdeepin/rooms) * [IRC channel](https://webchat.freenode.net/?channels=deepin) * [Forum](https://bbs.deepin.org) * [WiKi](https://wiki.deepin.org/) ## Getting involved We encourage you to report issues and contribute changes * [Contribution guide for developers](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers-en). (English) * [开发者代码贡献指南](https://github.com/linuxdeepin/developer-center/wiki/Contribution-Guidelines-for-Developers) (中文) ## License deepin-tool-kit is licensed under [GPLv3](LICENSE). dtkwidget-2.0.7.2/cmake/000077500000000000000000000000001325435343100147315ustar00rootroot00000000000000dtkwidget-2.0.7.2/cmake/DtkWidget/000077500000000000000000000000001325435343100166175ustar00rootroot00000000000000dtkwidget-2.0.7.2/cmake/DtkWidget/DtkWidgetConfig.cmake.in000066400000000000000000000003111325435343100232350ustar00rootroot00000000000000 find_package(Dtk REQUIRED Core) set(DTKWIDGET_INCLUDE_DIR "/usr/include/libdtk-2.0.6/DWidget") set(DtkWidget_LIBRARIES dtkwidget ${DtkCore_LIBRARIES}) include_directories("${DTKWIDGET_INCLUDE_DIR}") dtkwidget-2.0.7.2/debian/000077500000000000000000000000001325435343100150735ustar00rootroot00000000000000dtkwidget-2.0.7.2/debian/changelog000066400000000000000000000004441325435343100167470ustar00rootroot00000000000000dtkwidget (2.0.0-0) unstable; urgency=medium * Release 2.0.0. -- Iceyer Tue, 22 Aug 2017 19:38:45 +0800 dtkwidget (0.3.3-1) unstable; urgency=low * Initial release. Merge from deepin-tool-kit. -- TagBuilder Wed, 26 Jul 2017 17:10:12 +0800 dtkwidget-2.0.7.2/debian/compat000066400000000000000000000000021325435343100162710ustar00rootroot000000000000009 dtkwidget-2.0.7.2/debian/control000066400000000000000000000033101325435343100164730ustar00rootroot00000000000000Source: dtkwidget Section: libdevel Priority: optional Maintainer: Deepin Packages Builder Build-Depends: debhelper (>= 9), pkg-config, libudev-dev, qtmultimedia5-dev, libqt5x11extras5-dev, libxext-dev, qttools5-dev-tools, x11proto-xext-dev, libxcb-util0-dev, libstartup-notification0-dev, libmtdev-dev, qtbase5-private-dev, libegl1-mesa-dev, libudev-dev, libfontconfig1-dev, libfreetype6-dev, libglib2.0-dev, libxrender-dev, libdtkcore-dev, libgsettings-qt-dev, librsvg2-dev, libdframeworkdbus-dev, libqt5svg5-dev Standards-Version: 3.9.8 Package: libdtkwidget2 Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Multi-Arch: same Description: Deepin graphical user interface library DtkWidget is Deepin graphical user interface for deepin desktop development. . This package contains the shared libraries. Package: libdtkwidget-bin Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libdtkwidget2( =${binary:Version}), qtmultimedia5-dev, libqt5x11extras5-dev, libdtkcore-dev, libqt5svg5-dev Description: Deepin graphical user interface library utilities DtkWidget is Deepin graphical user interface for deepin desktop development. . This package contains the utilities which are needed for developing Deepin applications. Package: libdtkwidget-dev Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libdtkwidget2( =${binary:Version}), qtmultimedia5-dev, libqt5x11extras5-dev, libdtkcore-dev, libqt5svg5-dev Description: Deepin graphical user interface library DtkWidget is Deepin graphical user interface for deepin desktop development. . This package contains the header files and static libraries which are needed for developing Deepin applications. dtkwidget-2.0.7.2/debian/copyright000066400000000000000000000017421325435343100170320ustar00rootroot00000000000000Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: deepin-tool-kit Source: https://github.com/linuxdeepin/deepin-tool-kit Files: * Copyright: 2017 Deepin Technology Co., Ltd. License: GPL-3+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". dtkwidget-2.0.7.2/debian/libdtkwidget-bin.install000066400000000000000000000000171325435343100217040ustar00rootroot00000000000000usr/lib/dtk2/* dtkwidget-2.0.7.2/debian/libdtkwidget-dev.install000066400000000000000000000001411325435343100217100ustar00rootroot00000000000000usr/lib/*/lib*.so usr/include usr/lib/*/pkgconfig/*.pc usr/lib/*/cmake/*/*.cmake usr/lib/*/qt5/* dtkwidget-2.0.7.2/debian/libdtkwidget2.install000066400000000000000000000000571325435343100212240ustar00rootroot00000000000000usr/lib/*/lib*.so.* usr/share/*/translations/* dtkwidget-2.0.7.2/debian/rules000077500000000000000000000014231325435343100161530ustar00rootroot00000000000000#!/usr/bin/make -f DPKG_EXPORT_BUILDFLAGS = 1 include /usr/share/dpkg/default.mk export QT_SELECT = qt5 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) ifneq (,$(wildcard .git/config)) CONFIG_VERSION= else VERSION = $(shell dpkg-parsechangelog -ldebian/changelog -SVersion | sed 's/.*.is.//g') _PACK_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$1}') _BUILD_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$2}' | sed 's/[^0-9]//g') ifeq ($(_BUILD_VER),) CONFIG_VERSION = $(_PACK_VER) else CONFIG_VERSION = $(_PACK_VER).$(_BUILD_VER) endif endif %: dh $@ --parallel override_dh_auto_configure: dh_auto_configure -- LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) VERSION=$(CONFIG_VERSION) override_dh_makeshlibs: dh_makeshlibs -V dtkwidget-2.0.7.2/debian/source/000077500000000000000000000000001325435343100163735ustar00rootroot00000000000000dtkwidget-2.0.7.2/debian/source/format000066400000000000000000000000151325435343100176020ustar00rootroot000000000000003.0 (native) dtkwidget-2.0.7.2/dtkwidget.pro000066400000000000000000000004551325435343100163650ustar00rootroot00000000000000TEMPLATE = subdirs CONFIG += ordered SUBDIRS += \ src \ tools \ examples win* { !system(python $$PWD/tools/translate_generation.py $$PWD): error("Failed to generate translation") } else { !system($$PWD/tools/translate_generation.sh): error("Failed to generate translation") } dtkwidget-2.0.7.2/examples/000077500000000000000000000000001325435343100154675ustar00rootroot00000000000000dtkwidget-2.0.7.2/examples/dwidget-examples/000077500000000000000000000000001325435343100207325ustar00rootroot00000000000000dtkwidget-2.0.7.2/examples/dwidget-examples/collections/000077500000000000000000000000001325435343100232505ustar00rootroot00000000000000dtkwidget-2.0.7.2/examples/dwidget-examples/collections/bartab.cpp000066400000000000000000000053741325435343100252200ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "bartab.h" #include #include "dcircleprogress.h" #include "dwaterprogress.h" #include "dslider.h" BarTab::BarTab(QWidget *parent) : QFrame(parent) { setStyleSheet("background-color:gray;"); DTK_WIDGET_NAMESPACE::DCircleProgress *circleProgess = new DTK_WIDGET_NAMESPACE::DCircleProgress(this); circleProgess->setFixedSize(100, 100); DTK_WIDGET_NAMESPACE::DWaterProgress *waterProgess = new DTK_WIDGET_NAMESPACE::DWaterProgress(this); waterProgess->setFixedSize(100, 100); DTK_WIDGET_NAMESPACE::DSlider *slider = new DTK_WIDGET_NAMESPACE::DSlider(Qt::Horizontal, this); slider->setMinimum(0); slider->setMaximum(100); slider->setFixedWidth(100); slider->setFixedHeight(20); DTK_WIDGET_NAMESPACE::DSlider *sliderSize = new DTK_WIDGET_NAMESPACE::DSlider(Qt::Horizontal, this); sliderSize->setMinimum(100); sliderSize->setMaximum(400); sliderSize->setFixedWidth(100); sliderSize->setFixedHeight(20); auto layout = new QVBoxLayout(this); auto sliderLayout = new QHBoxLayout; sliderLayout->addWidget(slider, 0, Qt::AlignHCenter | Qt::AlignTop); sliderLayout->addWidget(sliderSize, 0, Qt::AlignHCenter | Qt::AlignTop); auto progressLayout = new QHBoxLayout; progressLayout->addWidget(circleProgess, 0, Qt::AlignHCenter | Qt::AlignTop); progressLayout->addWidget(waterProgess, 0, Qt::AlignHCenter | Qt::AlignTop); layout->addLayout(sliderLayout); layout->addLayout(progressLayout); layout->addStretch(); connect(slider, &DTK_WIDGET_NAMESPACE::DSlider::valueChanged, [circleProgess, waterProgess](const int value) { circleProgess->setText(QString::number(value) + "%"); waterProgess->setValue(value); circleProgess->setValue(value); }); connect(sliderSize, &DTK_WIDGET_NAMESPACE::DSlider::valueChanged, [circleProgess, waterProgess](const int value) { waterProgess->setFixedSize(value, value); circleProgess->setFixedSize(value, value); }); waterProgess->setValue(60); waterProgess->start(); sliderSize->setValue(100); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/bartab.h000066400000000000000000000015451325435343100246610ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef BARTAB_H #define BARTAB_H #include class BarTab : public QFrame { Q_OBJECT public: explicit BarTab(QWidget *parent = 0); }; #endif // BARTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/buttonlisttab.cpp000066400000000000000000000066611325435343100266630ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "buttonlisttab.h" #include "dbuttonlist.h" #include "doptionlist.h" #include "doption.h" #include #include #include DWIDGET_USE_NAMESPACE ButtonListTab::ButtonListTab(QWidget *parent) : QFrame(parent) { initData(); initUI(); initConnect(); } ButtonListTab::~ButtonListTab() { } void ButtonListTab::initData() { m_buttons << "Button1" << "Button2" << "Button3"; m_buttons << "Button4" << "Button5" << "Button6"; m_buttons << "Button7" << "Button8" << "Button9"; } void ButtonListTab::initUI() { DButtonList* buttonListGroup = new DButtonList(this); buttonListGroup->addButtons(m_buttons); buttonListGroup->setItemSize(200, 30); DOptionList *optionList = new DOptionList(this); for (int i = 0; i != 10; ++i) { DOption *option = new DOption; option->setName("aaaa"); option->setValue("bbb"); option->setIcon(":/images/dark/images/delete_multi_press.png"); optionList->addOption(option); } optionList->setCurrentSelected(4); DOptionList *optionList2 = new DOptionList(this); for (int i = 0; i != 10; ++i) { DOption *option = new DOption; option->setName("aaaa"); option->setValue("value-" + QString::number(i)); option->layout()->setSpacing(0); optionList2->addOption(option); } optionList2->blockSignals(true); optionList2->setCurrentSelected("value-3"); optionList2->blockSignals(false); QHBoxLayout* layout = new QHBoxLayout; layout->addWidget(buttonListGroup); layout->addWidget(optionList); layout->addWidget(optionList2); layout->setContentsMargins(50, 50, 50, 50); setLayout(layout); buttonListGroup->checkButtonByIndex(2); buttonListGroup->addButton("1111"); connect(buttonListGroup, SIGNAL(buttonMouseEntered(QString)), this, SLOT(handleEnter(QString))); connect(buttonListGroup, SIGNAL(buttonMouseLeaved(QString)), this, SLOT(handleLeave(QString))); buttonListGroup->clear(); buttonListGroup->addButtons(m_buttons); buttonListGroup->checkButtonByIndex(4); QPushButton *b1 = new QPushButton(this); b1->setText("value-4"); b1->move(0, 0); connect(b1, &QPushButton::clicked, [optionList2] { optionList2->setCurrentSelected("value-4"); }); QPushButton *b2 = new QPushButton(this); b2->setText("value-3"); b2->move(120, 0); connect(b2, &QPushButton::clicked, [optionList2] { optionList2->setCurrentSelected("value-3"); }); } void ButtonListTab::handleEnter(QString text){ qDebug() << "handleEnter" << text; } void ButtonListTab::handleLeave(QString text){ qDebug() << "handleLeave" << text; } void ButtonListTab::initConnect(){ } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/buttonlisttab.h000066400000000000000000000021621325435343100263200ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef BUTTONLISTTAB_H #define BUTTONLISTTAB_H #include class QListWidgetItem; class ButtonListTab : public QFrame { Q_OBJECT public: explicit ButtonListTab(QWidget *parent = 0); ~ButtonListTab(); void initData(); void initUI(); void initConnect(); public Q_SLOTS: void handleEnter(QString text); void handleLeave(QString text); private: QStringList m_buttons; }; #endif // BUTTONLISTTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/buttontab.cpp000066400000000000000000000062451325435343100257650ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "buttontab.h" #include #include "dbasebutton.h" DWIDGET_USE_NAMESPACE ButtonTab::ButtonTab(QWidget *parent) : QLabel(parent) { setStyleSheet("ButtonTab{background-color: #252627;}"); DArrowButton * arrowButton = new DArrowButton(this); arrowButton->setArrowDirection(DArrowButton::ArrowDown); arrowButton->move(5, 5); DWindowMinButton * minButton = new DWindowMinButton(this); minButton->move(30, 5); DWindowMaxButton * maxButton = new DWindowMaxButton(this); maxButton->move(50, 5); DWindowCloseButton * closeButton = new DWindowCloseButton(this); closeButton->move(90, 5); DWindowOptionButton * optionButton = new DWindowOptionButton(this); optionButton->move(110, 5); //////////////////////////////////////////////////////////////--DTextButton DTextButton *textButton = new DTextButton("Test Text", this); textButton->move(5, 40); DTextButton *textComplexButton = new DTextButton("Checked Button", this); textComplexButton->setCheckable(true); textComplexButton->setChecked(true); textComplexButton->move(5, 75); //////////////////////////////////////////////////////////////--DTextButton DImageButton *imageButton = new DImageButton(":/images/button.png", ":/images/buttonHover.png", ":/images/buttonPress.png", this); imageButton->move(5, 100); imageButton->setChecked(true); DImageButton *imageButton2 = new DImageButton(this); imageButton2->setNormalPic(":/images/buttonHover.png"); imageButton2->move(35, 100); DImageButton *checkableImageButton = new DImageButton(":/images/button.png", ":/images/buttonHover.png", ":/images/buttonPress.png", ":/images/buttonChecked.png", this); checkableImageButton->move(85, 100); connect(checkableImageButton, SIGNAL(clicked()), this, SLOT(buttonClickTest())); DSwitchButton *switchButton = new DSwitchButton(this); switchButton->move(85, 200); DTK_WIDGET_NAMESPACE::DLinkButton *linkBtn = new DTK_WIDGET_NAMESPACE::DLinkButton("Link Button", this); linkBtn->move(10, 125); DTK_WIDGET_NAMESPACE::DLinkButton *linkButton = new DTK_WIDGET_NAMESPACE::DLinkButton("Link Button", this); linkButton->move(10, 155); ///////////////////////////////////////////////////////////////////////////// DTK_WIDGET_NAMESPACE::DBaseButton *bf = new DTK_WIDGET_NAMESPACE::DBaseButton(this); bf->setFixedSize(100, 30); bf->move(10, 260); bf->show(); } void ButtonTab::buttonClickTest() { qDebug() << "clicked"; } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/buttontab.h000066400000000000000000000023511325435343100254240ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef BUTTONTAB_H #define BUTTONTAB_H #include #include #include "dtkwidget_global.h" #include "dtextbutton.h" #include "dimagebutton.h" #include "dheaderline.h" #include "darrowbutton.h" #include "dswitchbutton.h" #include "dwindowmaxbutton.h" #include "dwindowminbutton.h" #include "dwindowclosebutton.h" #include "dwindowoptionbutton.h" #include "dlinkbutton.h" class ButtonTab : public QLabel { Q_OBJECT public: explicit ButtonTab(QWidget *parent = 0); public Q_SLOTS: void buttonClickTest(); }; #endif // BUTTONTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/cameraform.cpp000066400000000000000000000041631325435343100260740ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "cameraform.h" #include "ui_cameraform.h" #include #include #include #include #include #include #include #include CameraForm::CameraForm(QWidget *parent) : QWidget(parent), ui(new Ui::CameraForm) { ui->setupUi(this); camera = new QCamera(QCameraInfo::defaultCamera(), this); viewfinder = new DVideoWidget(ui->widget); viewfinder->resize(150,150); viewfinder->setAspectRatioMode(Qt::KeepAspectRatioByExpanding); viewfinder->move(ui->widget->width()/2-viewfinder->width()/2, ui->widget->height()/2-viewfinder->height()/2); viewfinder->setSource(camera); } CameraForm::~CameraForm() { camera->stop(); delete ui; } void CameraForm::on_horizontalSlider_valueChanged(int value) { viewfinder->setScale(1+value/50.0); } void CameraForm::on_pushButton_clicked() { ui->label->setPixmap(viewfinder->capture()); } void CameraForm::on_pushButton_2_clicked() { viewfinder->setMirroredHorizontal(!viewfinder->mirroredHorizontal()); } void CameraForm::on_pushButton_3_clicked() { viewfinder->setRound(!viewfinder->round()); } void CameraForm::on_pushButton_4_clicked() { if(camera->status() == QCamera::ActiveStatus) { camera->stop(); ui->pushButton_4->setText("start"); } else { camera->start(); ui->pushButton_4->setText("stop"); } } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/cameraform.h000066400000000000000000000025101325435343100255330ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef CAMERAFORM_H #define CAMERAFORM_H #include #include #include DWIDGET_USE_NAMESPACE namespace Ui { class CameraForm; } class QCamera; class QCameraViewfinder; class CameraForm : public QWidget { Q_OBJECT public: explicit CameraForm(QWidget *parent = 0); ~CameraForm(); private Q_SLOTS: void on_horizontalSlider_valueChanged(int value); void on_pushButton_clicked(); void on_pushButton_2_clicked(); void on_pushButton_3_clicked(); void on_pushButton_4_clicked(); private: Ui::CameraForm *ui; QCamera *camera; DVideoWidget *viewfinder; }; #endif // FORM_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/cameraform.ui000066400000000000000000000044351325435343100257310ustar00rootroot00000000000000 CameraForm 0 0 506 268 Form 10 240 201 16 Qt::Horizontal 290 10 200 200 440 240 51 20 ok 10 10 200 200 310 240 61 21 mirrored 380 240 51 21 Round 250 240 51 22 start dtkwidget-2.0.7.2/examples/dwidget-examples/collections/collections.pro000066400000000000000000000032221325435343100263070ustar00rootroot00000000000000QT += core gui multimedia multimediawidgets svg greaterThan(QT_MAJOR_VERSION, 4): QT += widgets QT += dtkcore TARGET = collections TEMPLATE = app CONFIG += c++11 DEFINES += QT_MESSAGELOGCONTEXT unix { QT += dbus } !isEmpty(DTK_STATIC_LIB){ DEFINES += DTK_STATIC_LIB } SOURCES += main.cpp\ mainwindow.cpp \ buttontab.cpp \ linetab.cpp \ bartab.cpp \ inputtab.cpp \ slidertab.cpp \ buttonlisttab.cpp \ segmentedcontrol.cpp\ indicatortab.cpp \ widgetstab.cpp \ comboboxtab.cpp \ cameraform.cpp \ simplelistviewtab.cpp \ singlelistview.cpp \ singlelistitem.cpp \ multilistview.cpp \ multilistitem.cpp \ graphicseffecttab.cpp HEADERS += mainwindow.h \ buttontab.h \ linetab.h \ bartab.h \ inputtab.h \ slidertab.h \ buttonlisttab.h \ segmentedcontrol.h \ indicatortab.h \ widgetstab.h \ comboboxtab.h \ cameraform.h \ simplelistviewtab.h \ singlelistview.h \ singlelistitem.h \ multilistview.h \ multilistitem.h \ graphicseffecttab.h RESOURCES += \ images.qrc \ resources.qrc FORMS += \ cameraform.ui win32* { CONFIG += no_lflags_merge } win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../../src/release -ldtkwidget else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../../src/debug -ldtkwidgetd else:unix: LIBS += -L$$OUT_PWD/../../../src/ -ldtkwidget INCLUDEPATH += $$PWD/../../../src INCLUDEPATH += $$PWD/../../../src/widgets INCLUDEPATH += $$PWD/../../../src/util DEPENDPATH += $$PWD/../../../src CONFIG(debug, debug|release) { unix:QMAKE_RPATHDIR += $$OUT_PWD/../../../src } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/comboboxtab.cpp000066400000000000000000000046431325435343100262620ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "comboboxtab.h" #include ComboBoxTab::ComboBoxTab(QWidget *parent) : QLabel(parent) { // setStyleSheet("ComboBoxTab{background-color: #252627;}"); ////////////////////////////////////////////////Font ComboBox DFontComboBox *fcb = new DFontComboBox(this); fcb->setFixedSize(200, DTK_WIDGET_NAMESPACE::BUTTON_HEIGHT); fcb->move(30, 100); for (int i = 0; i < 50; i ++){ fcb->addFontItem(QString::number(i)); // fcb->addFontItem("fontFamily", "the title you want to display"); } connect(fcb, &DFontComboBox::currentFontNameChange, [=](QString name){ qWarning() << "Select font name: " << name; }); fcb->setCurrentIndex(2); /////////////////////////////////////////////Color ComboBox DColorComboBox *colorcb = new DColorComboBox(this); colorcb->setFixedSize(200,50); colorcb->move(230, 100); for (int i = 0; i < 10; i ++){ colorcb->addData(QString("#%1%2%3%4FF").arg(i).arg(i).arg(i).arg(i), QString::number(i));//support RRGGBB or AARRGGBB or color-name } connect(colorcb, &DColorComboBox::currentColorChange, [=](QColor color){ qWarning() << "========+++++++++" << color; }); colorcb->setCurrentIndex(2); // simpleBox = new DComboBox(this); // simpleBox->setFixedSize(200, DTK_WIDGET_NAMESPACE::BUTTON_HEIGHT); // simpleBox->move(430, 100); ///////////////////////////////////////////////Normal ComboBox DSimpleComboBox *simpleBox = new DSimpleComboBox(this); simpleBox->setFixedSize(200, 22); simpleBox->move(430, 100); QStringList simpleList; for (int i = 0; i < 20; i ++){ simpleList << QString::number(i); } simpleBox->addItems(simpleList); simpleBox->setEditable(true); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/comboboxtab.h000066400000000000000000000023721325435343100257240ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef COMBOBOXTAB_H #define COMBOBOXTAB_H #include #include #include #include #include "dcombobox.h" #include "dcomboboxmodel.h" #include "dfontcombobox.h" #include "dcolorcombobox.h" #include "dsimplecombobox.h" DWIDGET_USE_NAMESPACE class ComboBoxTab : public QLabel { Q_OBJECT public: explicit ComboBoxTab(QWidget *parent = 0); Q_SIGNALS: private: DComboBox *colorCB; DComboBoxModel * colorModel; DComboBox *cb; DComboBoxModel * model; DComboBox *simpleBox; }; #endif // COMBOBOXTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/graphicseffecttab.cpp000066400000000000000000000050711325435343100274230ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "graphicseffecttab.h" #include #include #include DWIDGET_USE_NAMESPACE GraphicsEffectTab::GraphicsEffectTab(QWidget *parent) : QWidget(parent) { auto *mainLayout = new QHBoxLayout(this); DBlurEffectWidget *blurWidget = new DBlurEffectWidget(this); blurWidget->setRadius(30); blurWidget->setFixedSize(200, 200); blurWidget->setBlurRectXRadius(100); blurWidget->setBlurRectYRadius(100); blurWidget->setMaskColor(DBlurEffectWidget::LightColor); QPainterPath clipPath; clipPath.addRect(0, 50, 200, 150); blurWidget->setMaskPath(clipPath); QVBoxLayout *blurLayout = new QVBoxLayout(blurWidget); QPushButton *glowEffectButton = new QPushButton("GlowEffect"); glowEffectButton->setFixedWidth(100); DGraphicsGlowEffect *effect = new DGraphicsGlowEffect(); effect->setBlurRadius(5.0); effect->setDistance(15); effect->setYOffset(3); effect->setColor(Qt::darkCyan); glowEffectButton->setGraphicsEffect(effect); blurLayout->addWidget(glowEffectButton, 0, Qt::AlignCenter); DBlurEffectWidget *blurWidget_behind = new DBlurEffectWidget(this); blurWidget_behind->setBlendMode(DBlurEffectWidget::BehindWindowBlend); blurWidget_behind->setFixedSize(200, 200); blurWidget_behind->setBlurRectXRadius(10); blurWidget_behind->setBlurRectYRadius(20); blurWidget_behind->setMaskColor(Qt::black); mainLayout->addWidget(blurWidget, 0, Qt::AlignRight | Qt::AlignVCenter); mainLayout->addWidget(blurWidget_behind, 0, Qt::AlignLeft | Qt::AlignVCenter); } GraphicsEffectTab::~GraphicsEffectTab() { } void GraphicsEffectTab::paintEvent(QPaintEvent *pe) { QPainter paint(this); QPixmap bkgnd(":/images/default_background.jpg"); bkgnd = bkgnd.scaled(this->size(), Qt::IgnoreAspectRatio); paint.drawPixmap(this->rect(), bkgnd); QWidget::paintEvent(pe); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/graphicseffecttab.h000066400000000000000000000021351325435343100270660ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef GRAPHICSEFFECTTAB_H #define GRAPHICSEFFECTTAB_H #include #include #include #include "dgraphicsgloweffect.h" DWIDGET_USE_NAMESPACE class GraphicsEffectTab : public QWidget { Q_OBJECT public: explicit GraphicsEffectTab(QWidget *parent = 0); ~GraphicsEffectTab(); virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; }; #endif // GRAPHICSEFFECTTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images.qrc000066400000000000000000000175711325435343100252370ustar00rootroot00000000000000 images/button.png images/buttonChecked.png images/buttonHover.png images/buttonPress.png images/loading_indicator.png images/reload_normal.png images/Spinner/Spinner01.png images/Spinner/Spinner02.png images/Spinner/Spinner03.png images/Spinner/Spinner04.png images/Spinner/Spinner05.png images/Spinner/Spinner06.png images/Spinner/Spinner07.png images/Spinner/Spinner08.png images/Spinner/Spinner09.png images/Spinner/Spinner10.png images/Spinner/Spinner11.png images/Spinner/Spinner12.png images/Spinner/Spinner13.png images/Spinner/Spinner14.png images/Spinner/Spinner15.png images/Spinner/Spinner16.png images/Spinner/Spinner17.png images/Spinner/Spinner18.png images/Spinner/Spinner19.png images/Spinner/Spinner20.png images/Spinner/Spinner21.png images/Spinner/Spinner22.png images/Spinner/Spinner23.png images/Spinner/Spinner24.png images/Spinner/Spinner25.png images/Spinner/Spinner26.png images/Spinner/Spinner27.png images/Spinner/Spinner28.png images/Spinner/Spinner29.png images/Spinner/Spinner30.png images/Spinner/Spinner31.png images/Spinner/Spinner32.png images/Spinner/Spinner33.png images/Spinner/Spinner34.png images/Spinner/Spinner35.png images/Spinner/Spinner36.png images/Spinner/Spinner37.png images/Spinner/Spinner38.png images/Spinner/Spinner39.png images/Spinner/Spinner40.png images/Spinner/Spinner41.png images/Spinner/Spinner42.png images/Spinner/Spinner43.png images/Spinner/Spinner44.png images/Spinner/Spinner45.png images/Spinner/Spinner46.png images/Spinner/Spinner47.png images/Spinner/Spinner48.png images/Spinner/Spinner49.png images/Spinner/Spinner50.png images/Spinner/Spinner51.png images/Spinner/Spinner52.png images/Spinner/Spinner53.png images/Spinner/Spinner54.png images/Spinner/Spinner55.png images/Spinner/Spinner56.png images/Spinner/Spinner57.png images/Spinner/Spinner58.png images/Spinner/Spinner59.png images/Spinner/Spinner60.png images/Spinner/Spinner61.png images/Spinner/Spinner62.png images/Spinner/Spinner63.png images/Spinner/Spinner64.png images/Spinner/Spinner65.png images/Spinner/Spinner66.png images/Spinner/Spinner67.png images/Spinner/Spinner68.png images/Spinner/Spinner69.png images/Spinner/Spinner70.png images/Spinner/Spinner71.png images/Spinner/Spinner72.png images/Spinner/Spinner73.png images/Spinner/Spinner74.png images/Spinner/Spinner75.png images/Spinner/Spinner76.png images/Spinner/Spinner77.png images/Spinner/Spinner78.png images/Spinner/Spinner79.png images/Spinner/Spinner80.png images/Spinner/Spinner81.png images/Spinner/Spinner82.png images/Spinner/Spinner83.png images/Spinner/Spinner84.png images/Spinner/Spinner85.png images/Spinner/Spinner86.png images/Spinner/Spinner87.png images/Spinner/Spinner88.png images/Spinner/Spinner89.png images/Spinner/Spinner90.png images/eLoading/eLoading_01.png images/eLoading/eLoading_02.png images/eLoading/eLoading_03.png images/eLoading/eLoading_04.png images/eLoading/eLoading_05.png images/eLoading/eLoading_06.png images/eLoading/eLoading_07.png images/eLoading/eLoading_08.png images/eLoading/eLoading_09.png images/eLoading/eLoading_10.png images/eLoading/eLoading_11.png images/eLoading/eLoading_12.png images/eLoading/eLoading_13.png images/eLoading/eLoading_14.png images/eLoading/eLoading_15.png images/eLoading/eLoading_16.png images/eLoading/eLoading_17.png images/eLoading/eLoading_18.png images/eLoading/eLoading_19.png images/eLoading/eLoading_20.png images/eLoading/eLoading_21.png images/eLoading/eLoading_22.png images/eLoading/eLoading_23.png images/eLoading/eLoading_24.png images/eLoading/eLoading_25.png images/eLoading/eLoading_26.png images/eLoading/eLoading_27.png images/eLoading/eLoading_28.png images/eLoading/eLoading_29.png images/eLoading/eLoading_30.png images/eLoading/eLoading_31.png images/eLoading/eLoading_32.png images/eLoading/eLoading_33.png images/eLoading/eLoading_34.png images/eLoading/eLoading_35.png images/eLoading/eLoading_36.png images/eLoading/eLoading_37.png images/eLoading/eLoading_38.png images/eLoading/eLoading_39.png images/eLoading/eLoading_40.png images/eLoading/eLoading_41.png images/eLoading/eLoading_42.png images/eLoading/eLoading_43.png images/eLoading/eLoading_44.png images/eLoading/eLoading_45.png images/eLoading/eLoading_46.png images/eLoading/eLoading_47.png images/eLoading/eLoading_48.png images/eLoading/eLoading_49.png images/eLoading/eLoading_50.png images/eLoading/eLoading_51.png images/eLoading/eLoading_52.png images/eLoading/eLoading_53.png images/eLoading/eLoading_54.png images/eLoading/eLoading_55.png images/eLoading/eLoading_56.png images/eLoading/eLoading_57.png images/eLoading/eLoading_58.png images/eLoading/eLoading_59.png images/eLoading/eLoading_60.png images/default_background.jpg dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/000077500000000000000000000000001325435343100245155ustar00rootroot00000000000000dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/000077500000000000000000000000001325435343100261335ustar00rootroot00000000000000dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner01.png000066400000000000000000000003371325435343100304230ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfaIDATXб@@EѻVͨFb@$Ӎft!&  $D/o|Y=l3=u‘SF`~r 9%U?)L=$I]{[QIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner02.png000066400000000000000000000003511325435343100304200ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfkIDATXС @ C$Q*Bb[s{=q}iצP wW-f 8!^HͩDͯn='``fHQ_M$IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner03.png000066400000000000000000000004071325435343100304230ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXc``HfɶoV lJlW000l3X(\a3?37 3Lsu(F!d;ykп.bϰaC#捂Q0 F(`Q0 F(0ðIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner04.png000066400000000000000000000004441325435343100304250ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX! AweuT$*x-K<lbx̂,(|O ? de3`N=6h@V-^H 8 [ʧ4.@kAAց$񿛊f, <O]ME֞M`˟_zsW`m Ti!p*P]$uQoЋoNW.ZtGV ǡ. 䑔!Plw&`$ހ3Ȁ.!e?e'v8pL/!^;=yIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner08.png000066400000000000000000000006431325435343100304320ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf%IDATX픭KAsg$rS&XVmb`sA?Ab0,b`]P8A1(!Zvc;ЮWźFEQۼ9װ.@/lOIj3(YYjhC1̻ʥQdV9{L1!/a#ܯ}3h,ǧ3Xxoz먧89:~?p,2&.`@|};ECo7Za2%Lo'xshxMN PaOR!4%t/=iv˓IݲF]?ŤXuj+A"@[rtr n^q`?ţA'ի2tpgvV(Vj..~ݎ~* ,)gc_ϱXW1g` xZa:~7UɓIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner12.png000066400000000000000000000007721325435343100304300ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf|IDATXOKQUZti@ڄeڴ+qZEnVATQB -A4#}6μy83C׌$COX9z;݈!˘*YWM$Q\P!ݼLz8 TX2U,THxx6 u.> 0#9hxN&Q4ZyRd…p;L^F+\Y |PqVN;,M~ja] דUO'4%749)oںv`#=$ڟ T‹-e.߷F7R)IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner13.png000066400000000000000000000007631325435343100304310ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfuIDATXֱkQoCIuA"" vb -"X6m$lE@@[m,m6vӍEI"1DMmK& Cp~e{fy %%%%;XB[g h]{ c n- CVp];]2h1Lk,iE5>0%1S0;s n u|f 4*ȒhpaPdza#x},fIc'pRVu,w[a@u)書mwz,lU*`B<տPN={Bw[i3H1C|^&n+ln`3P&>mUVƃ &g0!#-ct2y  lƢ[OV_p MU\Q)IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner15.png000066400000000000000000000010261325435343100304240ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXձkaυ r]4).]E\29Bt(88)Nf1=$'dPt`R*=mrL0Y. GNNNNNNN&ϰ5+v?v*)lV[|d°[XJ¡*n!›L 8=.Qn8.O~W a}^2؜ eiFI]Z\U<5Wz{x a_ g,BjϰcbOÙqTz0V 6"MFt}gH R1+axE<ܫ00Ӆb&96#{Z$D,nCFhF~ $bA{}%+' {-%tWKCL}Q |ӅFϚHs|ekS ޥ qVk/1AB2[TfS.3z} +.&>$ [ Gv  NKޭLkE܅'H nQx#BKp #߯íY{,6?Ua"|A! > DIGDx(@e2:c—lPM +cAS-@c8 Bh+l#aJs3P؋cȱ0}=7Zi,RX؂7l× 9: 1oǭ7;n)؎Ďa]K^Dkt$6Qmr9&Sm_2+]v1Z <>:jOw) [-ojE39ōm@jånݪ0= ʽŕfx\k[. ||)HIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner18.png000066400000000000000000000011471325435343100304330ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXMHq,F)Nյ%A A BFԭ[m;zҡNRP CvUe]zN? _WLԎKXRS `+Yɕ%NEړ ɕN E3+H{IC*ޢF[p"GVXLS'CtO0Vumtkб_ M~=W_w+ͥF\bu9R5Vhވ yyo4ސa~8(g 8 m&:tfynLPc IXw(b|@zA<2[H9T7m**¹JǵaEW L.Vԏc':1$Uba[\ XXvǞ#on?n+8^x q!x{l}IUgwt>)}0¶ /oIzIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner19.png000066400000000000000000000011671325435343100304360ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXKTaϕ!AH"jQ U0?`DQmͅq#Ehj+{!2,Y]i13pQsXA}S%1C Kx7Uڍ8+ yLZd0v14_l+T1olxS"o`y]5Ng^FW3!N9O_6tUt6l+JHGiͩ߂9Ώtda\U[HL@k*[8M5[jԵו =|[.vg~.?n Ƥ,bZJJьwP,S2:7;7{6O2'gK̅؍#8;+x=J+odIk\''Gpq@(&\ƒ& }^?iDZgډDi/~fhBWZA1Z,+Au?BҽIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner21.png000066400000000000000000000012661325435343100304270ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf8IDATXOqٞZivMn"'rRJ)9Wr؋8mJ=і(R2İ4֔V*Yx4@T(ap{;g(N v F JδQ؏kI/`_ux^FN`K"|. Kq[-|PVv"0V b~<)ܭ5jCTgZ'-39sӜZ/gv{9Jܪ> *U\r ЅSjO RHBk@*>K>zk־7L@y|,32 ;эX3>yL~jz/wt>K16Yj@I]ƭf7,fn!8e FX`7.#q2N be J+gѹb BV_:PoQ<0ihbJB.93\(`ڭ`=Kh @ ;e l8 )&>I]Ha%]Z@<) p 0!@&l& RK-)_8rk@x^d**+y|~ 7CcZBV^-Qa; dKk8WwU˿WukY 8'0n8gK&-!)`x&.138nw%%#aM+֤Xg =fV ہ'Zz: jGwΛqp<h@H+xgJh+%+OWO`'P7RN3w ]J]*Pv#8~( n:j !p `a((Pzʂ(}tK1T&νe n91 lg9R(  1Z5*  g혙IiY@:L^Gsʞ @A 6r?cf%= &!<g~Yݹ,BURooWѠ9IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner24.png000066400000000000000000000014201325435343100304220ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXŖ1haJZ(CSHըA XZN:iQq3.NRKiNnY]EA*Lф JK i%T$?}^/,$mx s`m2kǀ<-s=Y.ww /&l.<0Vh]LEwR\maL [q`N&~ik@Йgz,RNY9xE2D.\*Eǫ~NNTPhRQQ<>(~5o{"0Ls9(;μUVXV O`Ҩ u!:GP_2b׽:&=V#-i?/scԽ|]d~M'4<9{/>9*@fг|  `٪^p@8+g 8}@σoejaP\s,&v۱N_K7Cb^agdʞ~لj0H6+M˘3Z=͋,Mcdpx|zWt:%8L|S_WK+^6u)Y.`v͡jixJIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner25.png000066400000000000000000000014001325435343100304210ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXŗMhAotӵQJ *T~A='+MDAބT;-"Y!Jnyogfa%~^J.tcmZf@q978m?`l97?@|i`с>@'+'P3 `Yo _[POх݆xjF>JrV@=iFp.{Y}7#Yf\w7 -Ќl)g%~ PM \Wt ѾnɮDqEҦv$3If*D.@2SсY`1 D w ".p ؄uDX2Fl(Dj[AiU$fe}+>DeVw/'N"T#LkNnhJ\v"w篚/\iu8dsjڽ:9MfB)s몦eB8 SSWɡpqV .Gd)L%p{)mFs@T^gSIJC [AL~ }[hf y% uEHD|ρ&R x-phS-oTYd:؞Z<@H, L Ak5ƁXTY.7׿֎7"_`8NP#YN p@߈EiztVI1\99Me 06H`x\'z5oĢ:~hEu}'Jh#[F>iwh)%R&W[nW2gH7B*wUBýz5lD%تUhBOoBP3jpNP,@ݝzQ&:\5Vl ӡIWf׋A .`p6[# =`3ĒnGcP 3.ϩB%.~# W.!TkM>JRޭkA2nN,O~?ܥ58 uߎGruУjCGhf* S_J_eJE|̘*b}L ࡒ: '0HwS|c|f<mHE||ͬoә5,l!kSJ mJ$c=UYײ$8"2?ڌv1rα2 'Ve%8n,#R gwd^}=eKZz&Ymw] +S=IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner28.png000066400000000000000000000014321325435343100304310ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX]HSa9ӁF3eLZQ]IAwR$B}Q7ME4 -o .A Ҝ@et9 o|y~~&KPU+C~H^cv+m2PLL7SM[ڒs`r4O@v,:m& y1 ~7G`|4n Jՠ/BWTxq ޱ\#J CH >dje׆yRHUd䃥_[>e k)Jˬm2S$fkiHCΉEWFWf3:\ \6^L/#{^z) TGhW_ut@_&6YLM_onIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner29.png000066400000000000000000000014231325435343100304320ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXKa? L%"F;Eu A"{ҡ^ X; *0UboA0 A*y4&|NYX\aTլ'V;|vi, aWM#K^N[VW}l`c'2_y r \PB=bfcf/tA(q%zj~ֶJPMff_JحEjMIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner33.png000066400000000000000000000015021325435343100304230ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX]hPĵenUx".Cp AdTnЁ2PWRğXB;]NiAuxѴcam !ɗ}Nɗ%.6O!i.p!lm\+ts;px\yxZMj%V\},-Vۀ48gj%f^[Qj&9&R^Vb2pp x\0@I. 0y,voq{OB.6ہGvQu5k3G-ʁH)Dv}X`K=GR%? H==YI xI8\L[+gGBϳDRe^8==L-hAPCdҨx185Db5-G;] ĸ@ hPAӋW %C-p՘0XVcc# <)9aIkz4P ƌI^i MK.q{r G srތV1,,bX]@>Gh"[t> ZR=pV[JE}}ƀӣt3 VK|8gH9~*TkIU6HC܍u-t/IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner34.png000066400000000000000000000014731325435343100304330ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXMhA؄.-J"M!5# j=Ax\Dԃ/B)mo*UA/"h^,D<+؆ZMpM6I~>Xޛfv潅e+rJ ȩ%6S< V-%p{K. ^.&ooܫ~'>1WL@p N{ڡynq'T倜W,@F߾vFǹxSPa xD+Xf,N HQ+VIާBN^tY% w _6vf&VƧ=" Ll65ޝ[*@LW&`foO &㓈 혥~&;EӦ д%M&AI'eѿbZHAt`$<~ǯ~s:kBy߁^@?.RՓE` N8ca瀹_^=\ؘ z%+]x8c- q&)cbZk[ pxǯڀQɦw-v+K+_Z ?;!oG_ qd t36^ '.,\xp8l@_m{^/EkX96sW0$!{j ݀Gcag%_ 3a)IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner35.png000066400000000000000000000014271325435343100304330ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXAhP[;WLaA)!$zD,xă DD/zd)!eHڭښ5xhfumlXe t$}}\/ixmu_`ܬy#y@:)/5/w1-`.xMkoTҨުᆙ*Bcq` 熹[G)b*kKV˝pܾVy]U:꒪# JbUM`Vʪ9c~z0a+z-܆(M* )bm Ur`πU2>ͦf)%KnqOL˃ΙW_3.`[ U^OcEs+ ?yL]ʫuCha1?7{le0MzW@+p+av wS*0&7֛Tl1I|-Q=>EY"ʺw)EY0<9T1p>v0Zf Ś!i < B׵qhؗjn m3QC()rM>e=L Pq_iWO7 IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner36.png000066400000000000000000000014221325435343100304270ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX헿ka?osm4bB,t,Tt(J`". Jb? 8"" U&&ب6&MK.Ӓ4}} YÁ> >/dl?pk8+5dzV`c4dR0 0gtYqZxL׺ʪS=sb ,8 WHnNU:l/x6zYVǮ(ie0>^ЊjQ͞T]PbOVon%(+%RVښ0ү @O%: s2emL> ,O"d]&l+J=U`3!fw<ݷ(mv; `첵?[ނ?}loAZ=fHZG0f;9үw#6"p':u`iXU@np60p!8JW&pc9=*0Z/G;[@31c4ЪvɓIYL\\øT 0KfjkV_~[Ǯ0pYUL\*guit cYI?MM^Lzd0hBMW`"kXW>Ŀ 7IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner37.png000066400000000000000000000015011325435343100304260ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXOhP?fZ2 C: TJ/S4TvуTpzP7Oڜk- S^Ү~@S5 P5*>0U Ǥƌjw>@W0l.ysa!WR,p%ٰz[c-f 4 <RvPC8@g2 B.6ו@K)(JS.zL- zppД񅌟+U2m~{D;̱IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner38.png000066400000000000000000000014351325435343100304350ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXOHQ?3Y[ˆ Dv(C'2HxOa^R`PCBa QaKKº 2XVꬳtY{ke}c-e&f莵I˥ l7πzz ,&՟<z`^A2q!bEuI?Y@Bh-[-kMM,뤏u_0&fl> x<ƗZɝ9@Z+:-ukg+bzzݵu3`K4Ƌ  y L`!ٔf h3gh7?4r"!l6 eUʅRx)[AZp`˔?^ K 032UGX*1 R@},X;Sna jx6,%"y0w+!0F߿Di:-KqzApޒA`BQ _7;@4dZ3E5O݂ݥE|Be7ĩ#OXsR-{1Ne3e7xT.ČǁS,cYN$NQM/B,zxQOH,*% =C?`0];}VM RIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner39.png000066400000000000000000000013541325435343100304360ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfnIDATX_HSafN5`xDFT*F]QH!yEAtӅA @hW!A@#lɩŎt6a߼yޗk%*aځQQ:k beު4MmФhi^#+sgQ/. a{K;sH! $=_iJN 'tעv^fn6k +vOgIoԖN \UoHgpAo$5?5Mwx0?vn0 \XhP>p:ayYJӻ@KN:S; 3\_6v-NS t!*@-c? \z_m([[l()锿@08k<[4/i p 8\/U - m~SJ- @x͚֮_9"8ZNW\TŤ YC.;h4k-lb G -&7mu?aU4p4ŤNQ-j4}:'&,k- b@Q{ Ei*1,AIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner41.png000066400000000000000000000014231325435343100304240ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXMHa̴k(֐,A/J'8xR у$Х[ԡCH ڈKPDsR> 6Vy;쬍˲z43Ϗw%Y2n@h0\{E&dx]HjT]] T rn=#Wvlڨ `3KM>֯N5[V[B^1@A 4/ƀYk{ᄲ3BՉ . Կ@ܵ eGg|vLrD*Ncvy)h"[dJ]`W2|0Fv.E3˓*D,udk70=j{z%U:`d+Fȵ+ L/=1Ô SWw8u X56L= 075N@k}%GﺂNh[㞐W`f臬_ɴ~zP0e\Sۖx\[dZYlM{k2 ÀNSmK.U\)w9σ /(fgIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner42.png000066400000000000000000000014271325435343100304310ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXŗKhAylinIZEAPbOJ^Ɋ"E/^*Aki0Thltmm:MIvN˷3v?%6x埢a#" LZ_MǶxwLEc. HSi_kaz;*@d 8K*OA4ffz N5)Jxq; GNj\vxLp_ ]j\/z HuAYv"J$ 0$SH<{.Jod0V; 5 0XI!?d3Gc@ֹ7 SVRdXy:u` o>ǒ[{êQ Sv;Ks谒sC$ȅUjTl%Ōaʽ  ˵VFiC+pja~ॕ 7 Jߪ4pkΊv#< \Yo~ͪ[`%rzVPs\dܵIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner43.png000066400000000000000000000012741325435343100304320ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf>IDATXݗMhA٭Iغ-c =bDC AI*"\ Zڃz'Q/EЃ7m@#D%B6;4.lr^[Dq6 C4Ou[N{B%G\ch#'pŏm!L."?@ S"1x\lQ3}J o1k גuz_] {7N/ZCV~f)phRi0SFlq+,kW5 0sF 3`7gB6G`Z36o8/ѕ^7v&*ӨDSrXR|%2J`e1Xqii㎫:AӴp8l/@Nτ 'sZn_?D*n* |kI` Uu_W7_'?t ONNOz鬟HV*-̍}IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner44.png000066400000000000000000000012421325435343100304260ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf$IDATX嗱kQr1ZSPB  YE[:(A ]J!CBJiK{m&ϡ9|9mi"[|=wሃL K&S2EԪ~ඊ֯c5>G 2NWurρ2j(FDo@*S9%ƼNn-JoЂ.O#g 2;]5 L#H0=w> jKZ)nT3\+Ag.0r ^o|I; <$`٪_lDQ;\L- p@TVqA. _+0 PtS}auq[a j|1/9@BV‚'M뒝(hiVuIl_Pya 4ŲQVю_p p8 M76&))<|?D?>Y+/.;cBFeUc_KerD2RE]8\@ !o `U= ii>7p4sw5DF,sQB߀UƁXǓl~ϯ^je֟G  5xLg?J )N$ XG5X3ՕlE+(ex d7['\ᰱ 9ik=ע5~ktx(eſF 0x `1m-k"&Nk LoWK{&@=&K d y^uD4p1JO 0mN_>"oΞ$BwfΦp[,XuXfV\u%0J ` X%@8LU׼i5Wq#.d?M:IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner46.png000066400000000000000000000013021325435343100304250ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfDIDATX?hawjEȹdV.YPIBGq頳ࠝ QTC3ҡ'5PBO49$ _VL,>}F,e^^&fL:p脚Ծ!xTxR:祀õ>Ŧo*Z@!ptK-aP]Ӈ +@:eVBNc#WVǓ?5#Vu9PH , D{٤?lX5y4!/W׊z:`"?o>PX+"pM`VToOWޑSX84j-jxp0۵ \/SX' X-Of$ |`JV%%%3*\py%@G-lّR]&oԏz;UgzXNcFިOF ۵<Cp'l!oiɾʾzX%pqp$, t\$,AS hCTs]+| F?ѼjQ IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner47.png000066400000000000000000000012201325435343100304250ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=hAކ% xY[]!H J@2 ˀ,l,-u Ia -ș%ce.۽&o57}fD,!ԥ9~9d-U-0 Lf 0Xq1]aaQOF'0\54v72z4-߃7AFA8@UYe;v  rpuXʘXSY"0ٟۨ{W?P%-p!p^3f @y p '~Zx ;  `Jwx8 PD4{`(OZ=h+t:):CG^/N6pBN<|+@7 . Ϳ:La2;Б]5tU:0tA x5vnm7oH^2U xHGޏQH?XIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner48.png000066400000000000000000000011561325435343100304360ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX햿ka?ۚ ǁZQ=8Y8 GID78 :: EO̥RLV.Fu%m{;|>∍\\nNWK8SbJ'> )WfM(N7p zDQ_F{Ms{Q|?Ura9@瀛U^TFd޾# ,Ch4*Z]>Tk27^eF o;Se5O7_F@ >2Z/5#sށk`8zgpőn@\1w#"Vq$t! ط8߲CځIv] ?]φNb8luF5:^Di2~7|VZ)t~TQ(QlU }Kl&. 5?$`C`a/P>osIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner49.png000066400000000000000000000010661325435343100304370ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX핿Ka\b*=J .¹uQ,ҡةnLm dk۠{L5Jrv{<Ŧ%Ay#W S`uyVޑ8'ia`(Ȕʹlpr$<;$u^ Bi)`Usq!Ң,dy֘×hK >H^j}rwzCwdS *p;`ZrXTSGA7JDmu) y/ʡl7'`{"`pPrW=kn`I)w^ zŒk| M0Ǫ@%xdK-0d?*WF[d~q8S7,6ބ)q qIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner50.png000066400000000000000000000011041325435343100304200ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX픱kAC)lvjYK+U h'vimDia&  I\ ITℕ, ɡQ,ܯcvf2\RGe%w& j7!vf|Zt wj,Pd xIId|ڠ(0S~Ԉ9odr%UgFԪR ,pJ|; WK ڜZc h҂;ãM9pw |Xcs]j҇Ffm ًK%mv@>pf$$ oJu<_w gbmEvN#bNx \;-kp٩MҰwx[oȩ"8{-HLҰͅXbm|LԢ3IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner51.png000066400000000000000000000010271325435343100304250ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=HAY[]oT hDET-D6YIs`g)DF[- -P^`|UwSs) .\/8@ȦK>+8,'0Mro'X H;.ĺ5R)Hh;\ |`qfu PQ&4s]:֔ kVmG 9EɫZR"pQ@ ڽQb{Iz)@ gŇOҊU~x拧a߯4OIIIIILc_wZWIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner56.png000066400000000000000000000006601325435343100304340ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf2IDATX풽JAݜ',&A񏀅VA,m}_B$h #ACc=H[,vfcf (ʈquYr5ʬzv`{O'Zا1p0_r),ʟ4T3pKGuFQ+}ZR;F-^&8[}IJBltn$UѳLD>a%K+{Ķl!g=@ flf۫+;;CM:DIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner57.png000066400000000000000000000006101325435343100304300ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf IDATX풱J@Eϛ]RdIdShOO>6`%6v."&&|s;o{7;bU2Uro*ǥ7 dE8 g͋ؿs*Sotǥ@ˉ3`d-p <{]SJ =y-D*}K˳4*3~` *$`(0!lz`f{.C\8] !=,#κlH"mMUo 7<@|BIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner58.png000066400000000000000000000006151325435343100304360ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX퓱JA9 hl"J`' _w^{K+0XT0XCܯٙep8VlR)mjylh!mr~*0k[-^ezY hj 9 ų΍T͢NNB;e哑hAXy*%ilx^Kߚ~{wÅVY F3KͼǭFwvE-ZSIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner59.png000066400000000000000000000006161325435343100304400ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX?K@l'I  Wpuu.~n%]T1S0979x<qvhUuXSF!l;5lIsm΀ܙm Zi @&jT'a)zm~/,p^]$-1<_4~)d3=b™ Եɳo \0FT)ʘ'gjXk >e0@xDvC =JMjy/_9J>{IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner60.png000066400000000000000000000006071325435343100304300ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf IDATX1K@%mtK]EnAtwtuqi/pbA"*Z6K 7>B!TQEaMX=ʽ[hrIq1&E@+t?[UTw~N9}A=\4ΓU5uYS+xac} Jj`V2VtG^>~SO~a?CDTHIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner61.png000066400000000000000000000005451325435343100304320ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX1KBQynDAhr~pkn rhZ>AmQ 8rE$8CzRJ)R꿳ָyP`Xq= ]k\ _ho{{W0)Aw6>z< ;~Byt݄2"x^WGvs0*W$b&@h񔍒a\^r˅G7o ^y9|LIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner62.png000066400000000000000000000005131325435343100304260ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXб AqF݌RJ;ؼ+(!g0`Ul$.ucL:;B!B^ )P :P@VQqbj2NMym̳\@k q)(Nǁ}>;`)CGY8^`HAC't,%O |;Jo=s21.IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner63.png000066400000000000000000000004441325435343100304320ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXαAn6Itxϧ7D+: * htEvBkM&B!B!J|:<ҡ`U:-(G q_ vV#v34@<[>uso1׺MAV4^U+߼=u*TӷdIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner64.png000066400000000000000000000004751325435343100304370ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXҽ`۔"2L`4 lFb6I  *A$IsB!BT`uH1tN3dO0*02E"q[os\St 7<` ^-`$ ZAGM<=.qu9<w^X@}?wJ/FIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner65.png000066400000000000000000000004511325435343100304320ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX-@@ᷴAlR HR=jps&M KMSIfJ)RJ)c& \Ж̎=\j@v wr8]8 ETn(a"d璗LR1ZE@d0i޷I+M7IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner66.png000066400000000000000000000004561325435343100304400ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXѱAF3vlfԉ~;D4xVBO-zщ(t$l(7Aqo!B!Ui;=N&m,L![v^kS3 H}5@i&C #`k<8x[6txccpkdۛ{>@U ~'$cusIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner67.png000066400000000000000000000004521325435343100304350ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXҫ Q/zA%,6 6` A0l|1[usLB!wsQR ewuNY+h ]_clTs{ae-ޮs9ZD.~R\ ^q)f*IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner68.png000066400000000000000000000004311325435343100304330ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX!@DљnnP!A,p@9 @*1J4]&`S3""""G쌒=kq,)D@G<a1 yC!b?ʍyLV1E"gn+XW?D }IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner69.png000066400000000000000000000004231325435343100304350ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXc``Q0 F(P򯘑1[<8?= ;# c;#+c3=,;q/10000} :>c5-4lmP#g&Gb(` J#xy\IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner70.png000066400000000000000000000004101325435343100304210ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXα AD?`*h``` ڃ`b5FZ`V`t±` p`fffdS]OMZa+ Ԃ Vο%^:WuxNuji95{aff 4IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner71.png000066400000000000000000000004021325435343100304230ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXc``Q0  Yq&z!$3Fw:LQ L b L Ltw냿WAXHO020008r}f|Ch>#F(` ԿP &IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner72.png000066400000000000000000000003671325435343100304360ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfyIDATXΡPύX `R M`2GH^%<5 "" `}J_MR}[ƭ*c]IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner73.png000066400000000000000000000003731325435343100304340ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf}IDATXc``a N}a_z8 NLbLpֿߠ ̌a9R/)g3_F(`Q0 F;rZIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner74.png000066400000000000000000000004001325435343100304240ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXc``tQ\Wђa}_tu⦿"lLwu4wAA"ʨ3mGvN0/{`Q0 F(Φ!s ]IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner75.png000066400000000000000000000003711325435343100304340ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf{IDATXѱ@Eѻ;bЀm8MP)UM@l~|F|\ 8j ُⰷ]ݶeO{F5>Oa cK53?IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner76.png000066400000000000000000000003741325435343100304400ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf~IDATXc``0Iߙ&~砇]LɳreQ_ ȐM'uv#6Ay~Q0 F(`Q0 F)NIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner77.png000066400000000000000000000003601325435343100304340ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfrIDATX=@@V%Q8NH\\(fryIك1܎ %x) pDP0Ac~JuG#圈L4IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner78.png000066400000000000000000000003661325435343100304430ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfxIDATX!@F7&HH$g$8.p<u%SSUdļd@Rm+| aGIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner79.png000066400000000000000000000003731325435343100304420ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf}IDATXб @ Fg_ P "fvD)(KP@dGsQ,~2,lB9uO9-p*g^S85?|WibagR IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner80.png000066400000000000000000000003761325435343100304350ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXc`逑E 3/JSL-_W#yMNjZN o;?5 0g/C/@,c@,`Q0 F(`Z:UKIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner81.png000066400000000000000000000003711325435343100304310ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf{IDATXб @7nbщ ؎-X5Zɕfd ^v1IL,5ІOkd1~#Hn*]MXv}(9""""""-IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner82.png000066400000000000000000000003721325435343100304330ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf|IDATXϱ 0lPe DY3tTH)c#}/;wVnN-g]jC˶'me-4?\&ڰ<^cZ/$r~Z /S"KIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner83.png000066400000000000000000000003751325435343100304370ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXc``Hb V\ %5Dbfk*Fv{L,75Y! FF;33d\Q0 F(`Q0 F(.qMIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner84.png000066400000000000000000000004031325435343100304300ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXc``Hxw~:@ UfF5 z?-%`"I$+'*T <%Ѭ_S=sRQ0 F(`Q0 F(pw S v_IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner85.png000066400000000000000000000003731325435343100304370ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf}IDATXc``H *L*[ %`!U#;V&&7JDFVFi$,%30]$l(zJ0 F(`Q0 F(`I, IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner86.png000066400000000000000000000003751325435343100304420ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXc``H&y?;@iۿ ̌ sǼ\0A.##?BQ\reB Kf=Q0 F(`Q0 F(pA[ W$ X%$rrs;-e""""""J<}xIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner88.png000066400000000000000000000003741325435343100304430ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf~IDATX1 PYJFI<`'DM 6ͼn8xa"fR Cܺ*}APzM=]'$*@ zz^0nڲzoNhIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner89.png000066400000000000000000000003661325435343100304450ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfxIDATXб 0; 0K ejX>] @J L7nO4F0o{ŧss` WF \ } c%We,%fo4 ٟIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/Spinner/Spinner90.png000066400000000000000000000003661325435343100304350ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfxIDATX1 @?9 !VB ZY6l_|HLr}T^a'MҊ\hqe@A M)eIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/button.png000066400000000000000000000060551325435343100265440ustar00rootroot00000000000000PNG  IHDRZ pHYs   MiCCPPhotoshop ICC profilexڝSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/%ҟ3 cHRMz%u0`:o_FZIDATxb?5 ##3={?GIG M%{驘t50 y$y$S R&/q9 kY9ؽZ]WhEA0i.##cQ )(&?Faߒ"lnu=.!3V10085tM"tm+  #??Ys، {2݃fE}z#+֮o_y]N߿1o?w85"B)A/z_Dxyo jFbH0yqXaIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/buttonChecked.png000066400000000000000000000056451325435343100300170ustar00rootroot00000000000000PNG  IHDRZgAMA a ;iCCPPhotoshop ICC profileHwTSϽ7PkhRH H.*1 J"6DTpDQ2(C"QDqpId߼y͛~kg}ֺLX Xňg` lpBF|،l *?Y"1P\8=W%Oɘ4M0J"Y2Vs,[|e92<se'9`2&ctI@o|N6(.sSdl-c(2-yH_/XZ.$&\SM07#1ؙYrfYym";8980m-m(]v^DW~ emi]P`/u}q|^R,g+\Kk)/C_|Rax8t1C^7nfzDp 柇u$/ED˦L L[B@ٹЖX!@~(* {d+} G͋љς}WL$cGD2QZ4 E@@A(q`1D `'u46ptc48.`R0) @Rt CXCP%CBH@Rf[(t CQhz#0 Zl`O828.p|O×X ?:0FBx$ !i@ڐH[EE1PL ⢖V6QP>U(j MFkt,:.FW8c1L&ӎ9ƌaX: rbl1 {{{;}#tp8_\8"Ey.,X%%Gщ1-9ҀKl.oo/O$&'=JvMޞxǥ{=Vs\x ‰N柜>ucKz=s/ol|ϝ?y ^d]ps~:;/;]7|WpQoH!ɻVsnYs}ҽ~4] =>=:`;cܱ'?e~!ańD#G&}'/?^xI֓?+\wx20;5\ӯ_etWf^Qs-mw3+?~O~T/ cHRMz&u0`:pQ<bKGDC pHYs  tIME(%RdJ_IDAT81 @E߄tV A*$9'Hcgo!A$$Mo,>f-Nfw$IYtq%ŕ%i$-z/+ȇ$: ~0|z8c՛gziz=|6=z@_پlIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/buttonHover.png000066400000000000000000000063751325435343100275550ustar00rootroot00000000000000PNG  IHDRZ pHYs   MiCCPPhotoshop ICC profilexڝSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/%ҟ3 cHRMz%u0`:o_F*IDATx̔_HamHI.J0X"(4RFJ.BQ @XYib!&^,7)JH(Tڲt! /z<9Plc^㲈C@ʅ/]/@Kߔ~8HA{mY,''=V+ǗTn-<\_WT=,mc}~!IRL^IL쩲$tmѴ.Aou_=ߥx<BDmYZ $KքDb ֞)n)3\uӷ羞u`<~OzGͅWMu/=}QqT˕Wrv?,-w]Æ ^Q^d:[Ors씶ݎ. k$ɉIOg026:׆ݝOׯ֓9@EQ\CRXIIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/buttonPress.png000066400000000000000000000056231325435343100275610ustar00rootroot00000000000000PNG  IHDRZ pHYs   MiCCPPhotoshop ICC profilexڝSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/%ҟ3 cHRMz%u0`:o_FIDATx+ a#Anl(F1Y];p.fs j%<|- vρ{=23Pu4&@p1d?-z~13;6}Ir3I܏"7P Mqypdx\egcC//cB8Bcccccccccccccccccccccccccccccccccccccccccccccccccc ~4L혥s"(T@RYR *i)"k @XEKDY`4IJ\ŀ 5J4T[(J@\5͸( H,PC6n:dYcs@"5.A*(*i*TT o EP@ !@$H"ʔ T"nRI$ gQ,R3nԝԊYl )i @H3.YlX ( @b[ d&)u2)YQ`$i3cH$@ayX73,(E44 @ ̢.e,"ŖFUA@` !n@ (:LT*@X7;r7'DsYYmJ[4BJP,XؠU1(A@!TUr@P`PPBPtIb7ͼ'I(IR&a[(TPP@3 q\AgS *P4Ɛ@yX+ d&h)@@ $\ fhs,bͱ@((3,3QT5Α` (@:TcH,(Q SrX $%gVZ@I@eH%E`PʋaHPB3 A1$UKsjh3(hP U2 V$@ , @* wAEP$KA(8%@; @F bbQR+ӤRԚ4J+:@D̠Fo9U-2PP@Z2 (@ @F9P@ hi&@B JB sY3(Qc2yۋ@  a@`Y4+;@POK'Y:J`  %(ɰjZdUI!%SQiFNZAl ,XY4γ3(:35(( JpgHE Q$f9s*Y@fX& dʤ h Ʀtgr +4( R &hdJάXfQME@tEqt@( A(Y4 $\ƒ )id$Ġ S@VlJSq`VL@gW eBg@ՀtPTvP 1+ =5M2N $̰I@,M3@U,c3j"Mvt UAlR YP;HP*u$f3l3`@%L "f.J9kY(T ( ]- K+6@t @N$7Pe%P@ J P0 %=3APԴ@J%gVA T+:(4ϡ 3'Vl@7`ր!@ CrhC4 )s@. ΠΙ՚͹ PTͲ T%fY9̀+:@;i@N Yi( Z)( %nM1@(,,2 g:LYSR %AP nn @ PK%1Y%D i;Fu ƳgEh (,X";J4%c`3nnQD-PVu@&ɚJ r بi+6!@)ΦҀ1@,6g:KS*T@BXu@b%(qY ,Y)" P(dm(@ \6"JJE,n3DK`"J%fu&@ 1ՀT uJ "VXi;3@ Ҁ5JDP%X, *P PMY@s@cT,-K@(k;@=6: #y)$P)ў@:m( Y, % PcVh5e XP͔Pl B-C6J% Ә@f: 1PufJbgU@"JԃI4r4M!URj4.@g@\(MY@Jƒ&gTl)(3RK@]9 'F4)P5@Y ͪQRPMHDtѶt *(K5 `h%fgT&j -f3R!"(Q,טM@%JTJf5 @ɬT"Eزh NgP,PY%,F@K&tl s+zU!P3dE!Q`@ ̰^`ɶhՁ@ Y̽q%I%@7 - mdfjʥQuj4%d@ ,` %*^@lgƓY*()$W-e3a lhJ %i*2sQ j]BAϢPYwc6ZcT%C: ,P]ytdpQ e@ s@I&@Kehf &B;@1X%@ SRYun(JJ΁fε(5@cT5^{` "-PK9ui72 nD fz@)Fu Ah4 n@9h!eG`$Ԁ5RP#RPe,)@ RaY75Ku`,\m@(!1"^`5&4K2)*k %fkJPAMd73g:huLd lZz&XX ,JJM YMwrƨՀbذ:ssK9ul6K2  T="(YP3*-ΠTI{ՙI` ,PSRR@S@ /Lh ˥u`.V[mW-,ב@Nt5d*"@ ESr-Z6(JKJnM2ri`%ʀ@ I@-t, [4[i.mmӞ^{)@בFt*b`PSy-*L%%@ XC)@E6iPFDP"bмu!@P[3,΀טΙN`R㞢,XjjJs YIR+ hԀk: ۋ@S5,P:3d̠,X(c5e B ۛqd =@V53RN]ygL힗d`s7,%R*bs:-ZIRPrlTs5af d( B5 '@TZ@Rf4Mo;hP wJ,P-F5%@3ӏW>@ d,lE %J5f@%K @܀ X@"s"(=&@ 5YIRl(75* 6 X!-fDPX,s| ,TTܖIj%66֠3o\P1j@Y,( kyֳQ@ \59n13Yuzz,-,neh0Sbn;LmP@Y#f@hBիe.Xv@b@,1XJ͒Ӗ:d``7 ArK(PXHZ1j;L ,,Y6h΀ TUQrk@"ʠ"gP T8u穚v9@`=Fm-` m2[̨u (32\K٠(:QT PXjוK ϥƠ,鉡-@Z o2ꥌZހe@,5 -1P3Ldk YP Ҁj[(jhr .lZCPbf?^cS Sx`jIxΰ`ZtPJԈͰ3uT,J̀f5J1dLR,j @#@JjeXwPJZ iPS: ԰?^b㻕@ g)@ ]hKVR n@(5&(Z1P =3d #i-R\1t h!rQ@ט Yq 5 9s3jd%EjMH Crn@\jcTNq% b#bh4e@!cLjKΠK ןw 5 \;  0KejD@b램5%SyC ˘ dHR @R":EZkfjhUK(@ Y( h㸢 X%f?^` LEJCy.Z ԛ̖@fS T܀ &cT)339@k(,FM@S@Uȗ@5vcjYvPw.zBX@6t2jy%`-Wl (*MH@窠\fƓsYlQNXUfX1\%Uk6 <Ad8  5e75" ʀ1 (5  0u)9܀,.ZŦZK %s54@3(45!$gLjk8vTJ$@4&52)dW. f͠ZhPR,ԐQ@,7Jrt@@PBB bhU)`%K` @zS\1PJP}w@T(J ,ܔs툀4X!lPM@4jIMCS@ )@P jbwtRd uJ( u`($Q^w@5VJbh@\R,XpmP@5DXRJXS&UJI\$6{q Rt T9%(( tPJ Jk0R U,ɚ14s` P nP)Z ,7E5ER X"9n9n"p&U ");Q뙨P[JT@ JPNv-\"jARnN.Trʀ5Z$E54 CR6 fLЂ)  iŜF 'IJ<W.E@uiJWDԄABŐBSIYesu::`ABԺX )@3` jsk @Fu%@XEiP8^sj(t,KJRᾙ@"h W4Q fh5\EP* @X.T͂V@b9@D幝 Sƒ,"lRN㽨@RP@Rb(#Rm,̠ZeeQ @%\FjR5-R @PB J [8 LTkJ:gXKFW7Rږ 4 /:P SHYl &@-)` '\@ [(K.MH3\1$8u%!Hv2*beb fi +-(h,+Q ̠Z΀Hl@.TlfC4Sbș] o $jdT@YS T+7P+(Hb](K@  Y0 @ )΀`(t3u, F 54LҀP3PJ&kIN{"jJm(YS ZW* SȀs- Tc5 MbZ hdԚ*B]eR F,4@ܵ@t-dq΁"i, &u=L(@)P" ܀@(E X5J -Med4hEPZ55 k" PrҀ ٍN[p  @ԀMY<2PuCt6@lP ,h X@@RI,P Iä@Z,Y7Ŕ @ k6 *k8Ԕ2f\:@H@S r  ]m")d 1u b MI@c.t΀ @P@ hj@ Bi @TR 5Lk2&lƜo4=RzbiCPPR .J,I(@ZM@d閤@ܴ 3@JƦ52f{di=P8&Y Bs4E@` (P#"(@@b-")@Fe \1fuJfoP@,w &6@ MLn ()d,nH(0PX)2%%4@3hsUҀɘƔe!A*PΧ=d1d8u @tBayݭ P9.3t7A AeJ-Th( )fFY(4 MњjTŘ ft`e@gZ @d( URSy @e` `L\e* A@(,Q E @3 Vt穛 Ŝ!i'<95hHP+K nK(a@f QH*Y @JŜ1o(ʀSӞ[ͬ(5EK  -RL! %Իΐ(( AP@`7(ӞԀgXo9S׎5/-Z-fT3v @` I+e(Q3@(( PQ@ :ͨ(7,@zX ;Jg ӟlD*04f-@:fP2 -* .J/@!HPsj"iK q=P @˦@;l>Prk*l " UFfJ0(*4@Q7R酀Z 1@K K9jCp3@|*PBmsPP "TJ (*P4#e@.5@ƤnBDK cW l,fz, c:FW@DfI@YhԛPe@ *!HR@c` ".@Ko+7 @ ۍ" ehLX)/l  Syt Z(̆uI@LkP:fj@%T[,@&h] r@lԚ"VPkQ"cy=g4  ;Nzi *Q5I@Eƺ , () %Y )@%%ͼhu-ZV5D"u= YS; 8#IU(5J$f7` 5%K24k4 %K lR 7L m R"Y)y%KNPfubI%@, C*)Yl %A e`EYn70 6cVZH7.yJd ^~r &<,i)[ Z .56MHY"*S@Y*:(Kd5ňSZRDg=L*Y-%\s{KJF@6d f:܎y(,Te@),*΍%Pf -hVn9JԖn@GlbM@[@ J͠5 ^4U@Xk@R @&!BRl(3,JVX7s֢H+hj7"!J􂦲 '|)Zƨj@ƺ@hPƏ^ɎhBlb@-cR)@%2B1u@ar& A!> R j5 ݀@=:u祘 Zqkd^mizF YPSE Y@Rh!lԀ)eZ-(78@ zDT(5% T 2 ܨRf2KYBT[KlLǗlg5Ļ:* BPZ,$ HeZC5*TYhPYFƳ;%)Ƥ P( ,q5 eJm={+ z()`|WǧYsm⃖uEʊRl@J )5( Yk$M:PP"s)M@Ƥ$-jf,֠ԃ6K=:-K-`gB  yy'x0sYP! ( `07( ѹ3YYjkzn$A,(3Xj5 SRRRL]K@P)SVPR5 t-rD@yzLwX RQPhK R JJ`bXg\s.PPγcp1H (@܀C6P( ,EɣH6i<@Ps$3kZD^9ʔ(,Ya SJ!A `L)R5@JbYlFgNYDnDSy j@ B,iQ@ζ@T)4llc s\z(2fZa|bPh@fM(N @V΁eynQ %(51@(P E2@Si("CgD@s^e&z@A(:ɥEU"M(MdfVA% o/ʒ!HK"%(MIeƤ PP)P ՚3(UNr( d-%.w ,P33t jM(@ !A@.Z($%+XYboz)H%KPj\j@@, HA \ڥe e@vrRd47`T 1tO%4B$kP %d* z\vvh*%B2]Yh4EꞋ:<XQN,"Ҁ 2ܚ*EEiR.R,)R Ke/JZ:trd_xQB[gR j(ӕ@ɨH/IsHfB'5yc, Q( se|fE s.eBZJ4tt8_Bz,Waa FʂX tHXCC \nd-*u@rȡOFgLUe5P0pԆk\nu"`$,y@2y3*@:R ǣ\gIw@%^  @SrhrXH ݀@NWeĠlՀ8jBL!VNFh24lah!gYL[ jP []VjLZFNs\"ΑE4j\Yh!˦VGL]\͠ Kkeծ]R:s|&s)#+dz7-AN R˦A %::$Հ &=P[%9.#kRs (=l @TJb@L:"C%:-BE2K@@f]As /)X>RYru¹TP94˫S eyg\(\^pQs,IN@/U.FTb^Y9tr!z ^s|h((;5t,΀3D&gT Z6pk;HF;" (,s_-Y,tOu+]$<h fZlHB! S+zjSLGY: -E 3XѤNVBsc͊ @`)NP1\"rU6<@Ng@"NfgX P@AJۮ QԽ(4saMAK^uR iAo'00fcwy\Ylw(WZ ,'I:"rJLeH:@3K5CulݑH;eH(ŐqPw;b 5g\\S@!]gϝYZ R; PAE;%TB]"+KW9a$%0A]Ɨ6rATt:IW̼Ҟ|7n,47 =ҀBy#*(f^R9Z㴃+ W0:P!kײP2/KnEV=,jH@ ² X@o1M XM$HE)oN-po֓i祕)3wOT΂hԵy/+{1 Re)@;t5-غM2܄Y*y3זu(ԕ3u\هk5k}gRaVW =aZ&apr^MgU\ӎE+ PhJPry׌Pv@ ~|\BI%7"=wsOS=#nZ4X85 :̠PPR R;\ZXA\M i=5Q`z5Ad3*IјH,!h2d΀RN.u(0(ZeCsz3j))`ҽ8 6y[.kh:uY!5 .}]82b^fP(@P)@ Q`K Q@)E@  haQe:@R(E "Jg6 4{flOLϯ+湯\4cӮԖ,={k|@. $:Yў%pP E"ZE%j@E R@dR*Rٻ:@B%) @!M&@S8qJ lkrKy/&+Ϧvj<,Y*PQB- y "PC @XY)@1.VVf@Pfe @)@AJU꞉IL·sӛ^ip @P*RPqT%پm:lM|ӚOEZJ, @,Zd (( @ ") ˫"f"@VugbPd%Ps: gP.2yz;_2t B1TEѼ9W%eW+4vNj)Kaot("@K@S>ٚhԾzh:<X渖(T@Le3lhTZfX@@z<3PXPL@N6@+ cRY Nee"X&@Q@PY@( XV@.H@QM$;M0eyġ@TRP@P,R3lPY7 SR @7 Z *PBjm Ae% P.@,U@ T[%d(4#scr HtBT2bߟ7(ͰP(JbؠLF ),* *P@jh*`-%XE"%@%DJ"t#YcKRDP T )K Z͹P3@nJ͠PE€*Pn!*(X, @HJ! `b ( @AD5E K@@ZݖHK@- @͠D4%,)dBSH. T6@(J ʈ ` @e`*" fkB P)J"-@ SQ (MP+DA4Pʀ4 Š  %()Ae@̀ ( PT!fevZR@D"Pf5`Eű7 Vm R B( @i !@ &2ET"%E6P$QH fkRK @вX* B!@b4 JT(5 (K P-JeE( ()` C6PC5jDPB5e5% @PlB (J(,  MhŢ!H)fi" (bK` H#+Bf̰ JPSvACRX"KnTPp@ʹRPƐ*`B f)P P57s̹X B [,*Z3P)R[, b Q@Q(!u%ns9TP,@ h HB f6\%%7R@(E@-f *X .@@)J ZB%B`VWQJ}VR@F-^%Z XK`P !B54u.e(R B# P$Rƀ9P, .PP ,YP zY2v2J|, 2 Y@t p]\5 @4,@  @ &sX( RP@ S@ hLP=8LYP5@ lJ4ĠJY@SB.e,HB (@UF`&Xjȼ)@@ (!@5 e&gҐ`V!+53g\p1$U J %K Q4n@\JMHB [BJJXT((7 j@(RԟA8iȥ)O_=C5,R;TC5h!@ @*I@R@;+*f\*PRtNUѸ٣éyKyP*h@@M@[>#YMd*cP K*y-WJYJMH!@ G\gPR{}l'XJb}dC+\*eejJT"C%4SIॗY9:F7le @V@ P̰*^L^J*SiKf6n*)`y73f3^\(3(l(@F3tL(3Ӭzմ,8nZ!rh|gTfXIfj PJ,>{.V\2VD=)YЁu2t< <(P A- P"HKdaUPm=r7̹n)% %(!*JXԠvs8ƸM@  <Ҁ (R( @3YX PSY,n P Й)B(!>@(]F:`yW9|PR Tei2"E(ˬ @X!* 01@P!`2"pA3#8P*T^@P@P@P(PGFPQG%\iZT P88͂iP8zB(B!iZTr`+J˅ |dt`_QnEZV u1= ^#G -*giZT,…QqGO*8… 8@"a(PQtp1b`c28qh9-*9ú B (ZViZViZVBG|;O\PBiZVBAHQߞSx`d>]-S 8D|sB1CC~[-߀+~%۞@J3О;w[>B) .u r>r(G=[8Pa[|#E@|!)5o|s-AjZ(eMq?!-KRT# ήT?m%JI ;ؕ5Rs%J*yiS-*T 8c9RJ@T,v` #-KQC;_?[ǎJ)4X'n_D 6H-CJ?)#p*Tu0 ׂT7hX6O'J1%J,GEZTqy9Mgd<؋X3xC&\o(iQ4M2>w -*9"6͹SS>pO=[Qz{`];q3ʞzckFzysvVuTzs(3vwȕ7'9~n߅9nxУ>VKvv S :x㽕Ngݮ; t#+RNۊy!ҏJloݙZ#{aC*r;]3joس3 ?[37l|mmC-t2&9J4OS=wnzI- ka3lCڛ~s6Ć6GRrCCC\}D- G 8 }jr,P VX%l3B89Q$ܕ92`d!D~BÚKLBӳ-b4C^ïVL3e`iX18pB$@p#V խ=Qd@)8𣇅4ZFb,L=4`F_B(&zs ; Q !EiCҕz^"SaV!4bb3J 4yGdo`4w񓰞nr0Z-ak XZը /+W/2/:/9_i&eL%# VBԧ7Qbv r=xOX-։<6jHZ*TH<'-JzSspǣ6\j8^​gO.4̽y844E$$0@ P`1p!QA? 8%QEf3c1f3qqǂGUqeqx5ѸQe^ԝ'g|qǒQǖJ|{88QU*;=qʣvU~2m<圪U' *Jd}v_w[ N!=+ͨWVN!8̋]v*2*2*2*JRTU*JRuGq3bzqqqRMG 쌅ܜxQw:_{p[wQx=G^J,_J.1F2GVa0T]6*n1GnJ=(vC]͓Ԏv"Pƣdڊ(802c(*F(;GQ@"WV1/ݟQE`稢]j,x%QlqV(тpuK¤%#Y ,l`K%#(Ux@<T] -L3Qf;$uyuԮb7W0:%Mubi [2*N'qz=¶8G\%l{ה8x⮞E.Pў9g:v::n 0g*+p*.̘uB^rpiҋuJ.GӀ0T":o!'Ӏ0V=::VnpP(((((=Ώ,n/!|@tB7d/|Y#աc:9XSӆ}%1z_oqR(pM_zx!7QyW<*u]^Q{N+.<ěHBoWs =&O=!Ǘ4~hqt|9~yqsGqZ9#=>dEQcר.e_ވdh2O;'=>]z`?xFxr_d(gW!8s< _Çq ϧf=PcRT'ވ}a<]u{1tj]lI_KTp?u74PvD|ǐ80jP5`Gm; Y%R\Q`i8o;A%GLwX.;oQEסּQcE6}Q(RT8㱫/ qǻ8= LY +JS T{c|x:O4sq>G|+1q!b-i<B1QT; wqb4lkO``jb14aa 5sq4rQub:Gؗp m_,|_cmF֎s('?7o  Qqq5l^1ej-lGrԙH DP[8m?/F,3;hum]<ԉD:L\ˆD"))(DQ(#F O5%QEQp"S)e2LS)e2L((1E.d9H(2LWYbT%Rʑ)uJPGDZSdCCMWqir) D %idB6dBB/r\c0T1-_9Tq`ɨ7|Θ%@_HuG}'Ș>{"^WEQ[' 'm>Q5( %p ]I8`\se1ccTyR%2LS)2)2)1De&S)e2LSQEQEQEīuJU_"R%"R%"R%"R%"R"/??\qsCX~9O_{"TJb1 Qc8>UJ _ ]x6^ uNdt ceFTeRTU* PCڈD%2LQEj纾+ %0@P` p!1A?ʿ*q'(8yǝx.?rq)@:Ks?&:cs5ܓ]qzѝ888Mv<ڝ7Wy3>;'tz;;ghU6oi4Gz ?]5\8'=\q޸󧡪zI=)=8;G\xb2G9LapXN6!=x+1N;nȌiWF1la781;>ڹvN}GSrOpl\ʝ8s8DT5sÕßQF:lTIlÊbV.la QEQEQEQEQEѳ;(̟0 FoP\a;Λ>Zt38Sbޞan'ɑ<2G6sb 551cE4H͒|b͢9?6h-Y :ϨlwE:ͱݔWB:k+à)ΩQ4T?>Xr|O+a)Ɯ.QEW^F R:œ_$aEN((hW`д:)ԍ"0 NQE6i{8TQETtTEqT"]U?"F 1qt(1Š*_l*9W 1ϫ]к;:ΝEboV n0pϫn0LU Ҳ>qkO*‰)X Uuud-S\梊6U @[‹Ia rvP50 03@wvu>8udEC y:8 GȽ) u՘Saq(*Cg=}r?Q˸:Wvn88㏿TWn;SܛqU!p{r0wkMq\bQpgugȸc㎫80q\}GSQWW\tUM|88:;qqqqq(}\}QPwuMEPrh.E*f>8 rGbc;ύCx!ۏtYtu>tS("(lKqT'3.888|ˎ88e}GYF=9(v(⋱cE] 5o (|ϙ>gQZ MQ¸yaUqn7/!1 02@P"AQ`paq?_u #OUٔo-ïHW|OsjcSmu1ŭj`&T"k lGkzzv_Qw&5͍?>lGK}!Ѱ? ]76+D] ~1mDI;}w9 r髡LjhHK`WM\zU#TF9Pkw;Y#7ckۛZo66utA] I*J̤I$de$(I$.{u:NA3$(M5Ið$24u%LB0_k:jލaiJ\N![J7utI2$)ԅ!H=3)Dp\gUtRe%}eS2eVe,cRP}k*dleB.R>b/v79Lw9G۾> U|ƈPtؾp\kA*s|ƫ+saݛm5XuheUE9W?e!p) AS/e 6$I$I$I'aLDQ*(w\gT+ğoo!t:C3)q ĄTtC_~269K+z\_nNrcS*ʤo̧R T2KH\o͏vS#\W1ALj݋&>a->7N+RG15% vNUt2H:c7f%e|Jt>+ 01!@QAaPq`?!A%@`hhhqf37qnn}߳{1g!?SOC=?SOC= "t"t"t"t"t"B!CQD:u!B!QRFhS ;xP,1i(~J|ĞD!ad\tVGi30 EQEQE%>Hu$oYf`mQ\?8>$hV(_h;}z888888888"vXQEH# JC.0#m:>ZnO| M/ZSjձzx`$,Bp=QQgB&,ggaTE,_q}şiiiih ďTnu ֢/"3 40qղWR4AHu'Q:,IiP]4QhڡHp;*&7(l⬴<0y G>LHwM@*(av+"(wm{*`)VEAAƀ8şXJ{'Hb!\8D"sQPS'vC7qx#<rm<.)Txpn*g'z8şXN/0h~$YSfGw! fc|P} ټy`8qΣY86wy㎒zM\^ 0I6,;'7,~Ђ3Pl5&cQldbtXM-QqUqq`d) 'sdh^> f~/gS4u2/XO smhZB6 8`;3b쮓!@"ik.1Aͅd;;;nT`YIc87tp*"O sQ\!6) shc)4. APo7-h@<CN!Z gvP8b(6h&:hX7J;7|2"f3,Ԛ ^40 hB|8Ћ}>Ou э=\t KVAǗ|yI9y4f25 ێB .!Ƨ{₠.5%B]|pG44 *6yRCWpI̵4 E6mBT;43?-R&ՅD]7רQSM J>b / 3pZ% owXafE5 M$pg+=  + <"bK6z\qvlqz486 N)/qV8$=a$`bx;UGhB"Î8>>CWmF͑x! &icJ9; 8UhEcVF Vs(q|"uFcw ]b ; Vu/q|wP g" C<'T&kgJR4'qFL`R)$yjO+nDG$x;$tciҝǴ'a pbҸ4@(rÛ3CΎ:Fa3q<uW $l8ԑb^> xR"10ӠAAJ PsFjVJ S A g盗b(:|A: ðld;#G<ᨀA睑psB:eq\Ezw L4qœ_;@wFS`΀EEDYR@8Aۊi[q `6x&X˄6qD'h5ϝ_ Z|mF5jj [wР7 F v D]qhnHC΢l0Χro 6s+)*y Fuma!#L u"8Cs`툵q#88 p %7dL=D$| O,cB_yx$&bX4AAfy/ ViQE>4 VlH6}c~ˍ_VW b l. L!^. O@GIǎf\!p8j8 `E /7pDL^P)|Aqqq%q sKCs7o JygWq\q EG%m #L Xq 7&85.ϊ(EnXco WdY8:IT)a: J-,aps_, @Piǡ@HqTs|tEIŌ,֢AeQ` J -9NmJ8A68Y ;$MC\RcwYQ|HN0g:u5RUoopE_L Pd떠&12pVz[q@hj˭D ނJ`z[9 W':Ƥ%-L|z ql [Dq:aQxR¡NhpjJPqӄGcJ8#8>łT%F:ΙVN1FVi4=8gi.0OA@ mfH8;eҲ5IAv. Ps%B_x EVG&B 88V7N=N-S6 Qps/A?L}jIw2 b> ބV Dn1nRF0bQL6H.es9ZN*7a,PE6MM6PFB*5$PH+-fg00` 󎳰<1CN;x!3:\oF*GI$srO [xN;ܵ<1e4%#7> Qu@;.O Y5w6u@p&|hcȲ (pigއ0V 1  $Sy"rGO0d|7>DP&VfeKͦ͐"L/.8YO5qǠx~IB =kCB=DzoC59XqVXI_8.aHO 5>Xc< O HRkRC. ]zSj3 6ޏRY4!PL#<)mF8P/QWJ4/7 :E: QEQS:!mK8 &m 91h5_? s|x 8($Bh@EJ([4ؘ-c[q=oBsaO4;3۟z<xnV,šMCр$CCZ|ak׏sߟto53:ct Ûh Q ?N@uZ@F@4ƐT8mTCn1[:<.oUaB6 CWvGh*Bp ט1c~qx ס1^!OPd7S1y"{O/P$(F~ 0S91h\DRF3 4ў꞉tNZj>?qB~#z F17ĠߡXq!u *6cCҏ!Ї T :dT8١Zx'H!ԵSޤO2Ϩ} }?cC=F#ѱ:$t 0nh;(:,Ap1azlb(@4hvw&t!.aLɛBcB }S uPv4BT:2Y-zP?Ȩ_T$k0F! gS^XxCL+`C 봡"L۸`-kjH$t`;Ƅ/S aqP-@NE dh[(] |QSZ& A RO@)!O+3Z[i@f4Sz)5J[Ns@!V0wє3I=K7R80d&D>@ a ZQLuH< a~ ?y3dtHHD)@qHyi;rt;'z?`@!hP@dz~П!ROEA:-FwRzX@D JQ=q7:r _V2]Ry5(3< h'=N`A׳AA AE` ` ph;P" z?1t>voaB B;):Gɹa, w5 iFgh*!Xټbd꧟ zLT/{-g6CbpF= A _Pv|C zgAC@JƯ2}} &- pzFEOW$I+jXш )yЇ4t?3 T>(G;ABQAf/QA'OGa-h[P3A6Aćm ЗM389c@A@1q_]@0A6QfOEPvD5&!Ikt` 8fl5ez؄b?h (X࡞QIvG '1=`REg:a CyT8A0ЙzԈ3d (NL{qp32֜#AL#Wv3+؁`@ ep{fzuJMA[=2jrϨ)=tuAbIg7 {7'hz-EXqA(= { }(g~)bО?'DQ^?YH?sȈfbz=MCd (b1lP`"jĘ#;gX{ 2=!/4ot>@{G=bsЇz 'F{|$L =XOBܟ $L3F[F>LCz8s nP` G`o@_ @f8 |!'O>G_r?l }Ư,1 'Bn{S`!L׆Xꇡ# ƌBH440pFIֈX$`C|O7`30&aL ]@ P#Aq! -ݙ,!?`@g< $GA̡ptj_ĂDi~5n͎}s} :А3ci7=eS`3PlLOS}| ae2V9G3x@ Bs `ct!r#3Ăt])6͎X1B=Z9AfH>({r'~76! h&x\![/yCZL :fv P ;pO/0[gwF2y #15 Zjk44b6^b0uqԡn Ez M5 N, )вs}>I=ƀCuhj'@}D";xEy:ߨKAD"J-qOA֟Z(EQEQDb1F#b1F((Q 18cLQ*s{? dBTÝ2}#c p`}CB(mq՞G3~#eQ0!`vgiB_Pr_cH*3 2'(b%eKEQEQEQ@~ ߒ0;$}|7seXv/gg:?'ov3VM@8$j{Sڞ=Oj{SڃeLP5I ?` 1Q !]xJۏH- Qad7U3s#hQj$LJ$='(KIjmx`P~, Tm-MQZ.dOW=_~W=_~o=~!?+rټ.*ިj#IcBg@}Sb1Mӯ0 !@RxG55ajf-4]Hj# 1~ k݊N3{^fAnX 8*fH&-\.pL s7fa bt"t"t"t"t'@ Glp`'pk4:BBǂ.:_tX}0!F ,ysElq9I7Lz΀a@!ï. 0flBH' O<.{x;j-`ab~d71ˁD?0dGلA"NoFx hhgK f6|hHSɗ-8l<c?t :q$"$zYPɉ"1q/SKrU m$I$I$InhI$I$)$n6mmm Im>Im$I$I$K}Y?m$I$$[mrI$I$I$I-rI$+mm-miOmm}HK$I$$Cm>IdI$ mmRI$[dEJI$Km`Mm)Cmm[m(hmHK$I%$$$I'K$smII$MI$A$mi[,KdImlz%BK$I)$$I$I$_\=m6I$I$NI%$_&Cm$I$DmsI$JI$Ii$LI$I$mI I CmmB@$CI$I$JI$ $mm mmI$* xXI$H6I,I$F$qn2ImmI$9I$I$BI$ !mmm!I$sm6*a$Q6I$ZI$umm)$^Bn)mmI$$m[llkm$6m@I$Fm%IIeI"Ipmm $I&m6[$mےI$mmvm`"I$Nm m,$&AmKImltMmm-f%I2I${mI$vmDI$$m%-$m$I~e`I$I$ĭ@$A%2I!$ I$nmd$I%mV;mmdm$Ilme$I$I!$$ImrII$NmlI$I%!$jm$6mm`IdI$IEmI$m|OmH@I$\l,$ncm$I6If6mnQ`DI$I)IGIfH8Zml 儂I$[i$I%[mI$I$e6I:$Ϣ_@*`I$5* NBItI$ I$nmmi$I#mmtIdI$IvI$dI$@I$I$HI@RJ$&I$gmawizSmmm_قIdI$IlI$I&(?$I$I$K/I%M$P@I4rR$I$':mbKmmdm&I$I$lmm1I% !vmmP@:I$I mjaH[mmm$I%mI1mi`~䒅FmlamI$BX9I$Imꝶ+RIZDmmI$yI$I?mkmI$ml;mmDX֒I$IVI$kjӶ{rJ[tm mI$I$Iz[m}$I$p_d[mPl $XܒI$N$I$[l6JDmI$עI$H[mڭI$I ?$[mk\I$O;lPI$[lZJHHtmI!EKmmmI&߲I$@A<Sa?#C,mNGvJo$?I2I6@vmmmI vA$O$I$/dI!mmMS4LG(Im[mmM6I"l $I$n?mI!HmmI<4lI$fmmؒIVm[m[m`e $I$Imm$ڛmI!ݷI"IYlI$vmmA mKImI$vjI$@ $I$A$I$$$I$ēkmII%LDHo:SI$mm4I$mIMmI$VhI$H$I$" $I$$I$ԒSm:I%MVhm$`m-l$I$I oo$I$I$VhI$I$#)$I%mdI$Tgm%I%fimmmLI$I-my$I)%$I$Gmܹ$FI$^m Vl$lrI$KضmĒ}`Mđ$$P%I"%Ѵ$;mI$LI$I0?i$mI$G6mn$m]I/d$ 0l2I$նh ߴˉ$J,m/m׿I$A9$Em$I-I%$-I$Fݶl$z[mδmm#m$E MoJ$I#>i$$mMI$A;mئmGI$V֒I m`HNmm'm$ =nI$$mI)tH0%O-[fI$M+mvm$GI$VI}mŶ;mm$m-ڀ}e4I$6&I#$WI>I$ImI$I${$BImk$Jm 6mm ,cdI$tI%$mdI&$;mI$I%^AI&%m$llI46I$I=,1mmI*-Okk[mI$FI*HvmIm lKHk@I$I$mm*H j@*I$bI2B-I$NmI#{ImoO$HI$I$ lmhm$-II$I6amI$vmI$ JIU%nmY$I$I$I$IamI,$0 HIIdI"mڛmmMI)Lmvm$ rڀI$I$ԎI$2/mI5?uTFI?ILIi$mζGÐג_#B?6})$mmM&mMI$m@/yI?IlIrI$[mK]ⱿT9}<$mmmmI%II$mmO|mRI?IiDI,$?ev܁2"*ɹm?o$mmmjI,I)$Hmm*[fI$=I7II$$ua5'ɓg$.H=emZ$mmmRI'I%hmm$J*$H*bI'-ހIMIm kKbfدdS$$J$mmmRcmim mI$RK$I$_I&--ǁPBI#m!|[gdD;DH&ӛmmm˶kmid lLI$i$IW$I&--6$FrH.m,r[m%-V`$IH5{mm}km$rd m$q\I$ۭ-6$$H?ԙ$mhr[$Ѳ6'$' $Ho{m;m$ے`Cm%$?]km=-?I.$$I$mN=K$#vZ%@ĩ$I+Imm$ٓi$Ht$%)Wm5 m#ڒI$MVvI"mg'I$ $I$mm%i$ICﴔI,M m$I$I޶vRhRI$i<{d|%i-I$m7ot~@i$I#\$I$} )mm$DI$I6ݶڶI$k@do$ m[fmИMn: $Fpu{mrI$Rm kmm@-$I$I&&VM-Y/\4ŒI:%Ѷml͟#`k{I $LͷmI$NBIm|-,I$K*7kdɲͼlg km=m-\[lu[nI6kKg@+II3mi2m'BImP-oI$r[!l /m"P \m@f (vlj앶mmlI$FZoܓm$rA$EIbڼ %I%;6mŻb@%l I,@/'0a$d"m)'nBliwЍA"km$m ifڼ'Ho@-撠]m $ $ iRH61d!(m[ %#daj̑,0jI$RIt{x\}ԜH m`f @MĒ$.vIާuHm 8%I7)ēE7)$K6d&JMoJBRI$D-Н9kkqJ6 5o0@ am6o $6?jF76ì Llg I$34D iBx&?A"2+M$8&X1J_@GEJI'ȳH&m@8-%2lqJAI fƶ-Zkn~rA$K $L$ ضM$oKkm :Ip1m\7I@ŢV$M4mM%mmğG\UؒKvtI-$L$f[$EH+MwnAKN=6P m;ĒE$mIe$ջ"~1+)w %I ?LdA%JI7'f! >ٶmp$ݒDep>MzK>s򛨚Jlyض$ k6liAII3If%~$2Y[[vٶa̒{Hm3 K7i7m[`P XBX)"m;%{7oIimlAoeKא?vY$Y?K^I%xOLmkԗi;aPK,X߹#`"V $IV96'@?m$hGK,mRI$mvIAm$Ia$HI$I6m"I$϶D+mmlxARI$6{m[m_mlI#;m$J$slH.mjI(RKmI" hkmkm$n &mm[mmmI$m'mQ$I$I%m[i*I"I$o m-BdI ikmnm$)$k(=em[ $$Fm$I$Iimmm@ im)$fm0 mvK^$y$/`+mm$@m@I $mſI`vemؒI6m$=[M-TBI$@mƔdG$2m@7؉$_mYd@DRK$m'HmRA- rI$I$I$@ ՀmEV/mic6b@ROo$I$ m&lM$t-i*RI$ͶmrI$I$ 5lI$}mxI&m$4 g6p$r}I Al$I-o$6I$ݶmm9$I$- $[mӭm~I$omI$m@I E$mRo $VxIemDmI Kfk+X mm "I$Em; m _Ir`?ܲI$I%M pmI $ dIy7:/bI`"Im%$I$[kmI*RYI$M'I o,M$ $@ 716mI$m=I omͶ؛-iI%mRIRfW{m8I}$KMRL$Im$I mm A'- B &. I$m$) CRXmH?I$ $I$PI$Ii$ITI$mۄKmI$zV&TIMm$~}/[R~$@ml $Km@tI&I$I(I$$I$vG cf=wIo餅 T |0-$KmKmirA$I$I&I$I$o};mv@;rI%m)%ӠjG+bI m$I$me$omRI ImimSdo"I$I,I$I$[1HͷlH$I$=mI$IKbI$I$Iu$I8w#9mm?miT%obRH~͸II,I$M%5m$Im&I$I"$2KRI$'mI}$mmm@)"&x)6nXFKHdIoIjmmI$I%@lm$woom" 01@!PQAa`q?G`˗C=[-ƒ=J*TQ(J%%%%%?'J?%DQ-?i'O?촶[-el[-˗.\O `ze˗.\r˗*\]Gp.\Pw?V˗.\dMd!C˗.\r˗/*VWQż;;{x\r˗.\A*%x^[zܹr˗.\r*Vfz"Fl̚OQSe=/-> RQRJ(J%RJ*TRJ*TRJe2>gʙR/ e[Ř B&7DUi~4/-7 j*W}m^aH3)MG"~4qa+Hb~XYGRyM5+(y5PouoC~#!7^ZR]Rn U+I̓PoXֵƷ2ؖJl=kR͉yu,~MB}YO%/jT_SD[ܗ+xF j )v4rQm<+zԳ~v~}*(.^\(}2L OJYYYIIdԱ[n^O |VҴ\xl/?`9r5/ep_CJ|*1^靃:iG=+Qm;5O8WE<.TW?\_N#.6-’u^MY>2vʿ+mg#pIײ}Z{g_~HL J7DL_={kZ~pm5~ƲJ @Wf o~v^w+JVíwJ˦}x~;.>o *T_f ZO+nFFTRl7v8JVfx1`o Қ*A|An ^SWM!O4uXkOC'k۞ qMxħcCu\3+q/Di^+@$U:h umLϡLor6=`əO*\L_<6nLNn?o A鳧!㦷iU}CV&a^P)ud>5%zړ[ w8~B LcJoý.&!nĽ=5ԩ\+ĸuw\ wWrr?U8+RRJ=ba'l\ ו969,^y cGΥJ+(TIRaί `xӃka熡d%Jr^Q:Ju}CY,)B/C3Ef}:ot@T њ[ wlR+Q寠JprJ{qAo֊` 7+K6=jiPӼfʕ*T\$FnʥD* x| !fu+yR` ~.N'/xW40)^QڕLUx_y/NITRxTJu|FڡUmJ~|N3J*TRJ>K'7P*¥i?wSs[B?KP\[ΥJx_;iT.ޗo4Shzʕ* <,s|o6FHh<Wx_}NNI_C{x_#{\GΚI<+_:19ش\[oxW#ˠgR2_9t|k.UuʥJ*V*),/1ƼN/MJ*Tʕ*TR`Ê v0+@tkV eJT1rw;B~dw?/n +y6=z)Hr˗˕˟' N+AߐQ~04.\z 5*TXoCf߹Z^oer\rRJ+':, zc쭇zoQ{bs~[8v=43ؼUn;z]{//{l7e`,Sعמk;y |>r_-7ur5:Qu0'{oe0u9ܹ~Mp\f׈*}G{ ]oK`5!/WJ3N^Twq|n}?wU\rRRK1ֳ /]/U* A&oQ?WP>e2 J4W}< ._JC++YXXplM7/{]>` jTθ^jV~0aY/Cgҝrd?\THVg'V~<}Fo݊]+A~o114Vr;n^k޷'&nk3!5??`uj*T&o]lsr7.z^+SP5 h!n:468x*uJ~~o+|F*T8O!|[E@ņU*T- TPBzbQүØLRJ*T%AN,3yؿ K9x) W'9ZKKKoLQڱaux-k{\Եܹ|\u˅O?["b~<S?_+\\[RgϐֳSܸ8^w' %8jg;J<. NL"d7;[k͐Q|K8{|"W  p\T/7 *tA3Cc73Fu01e"yTE#EDr;p>?k: .\xVb lCM&LkE)Irw!'X˜CP1>eNY&Ⱑ pxH|G"popŘVʕ·^`%?14"ʕ*WҲLRlRB%qh`VJ!h%OO?1III RoG)qRzuiKKKKS)J.(=Je2ߒЂǷODr)F˃x?[SO R| W+Ek 9b|^ Cp !l 3Ɉ}R_q/PwDBK\C!7.\k oOEc,Hh~NwS2>%zEm2J~J69ّ> ^)+7N/T@gQ _@ zۀVxه/o(#< k7.^Eza/􏂥}Ã!|}%/Sx0GS}x]˗/o2u2 /e˗.\n@" |߇迉ŗ"K@M"Cz.\ Ú>e22e˗.\r˗.\r˗.\._Jу@tX?arR^C]O[P+%$)Ur^d)O|\r˗.\r?--/~jssssrmJ~J~J~J~J~J~J~J~J~J~J~O~J%DQ(J!f0ۤS/+/A/5*W&TUy:Gf U{_M\Mfot;oh2'X5_wz6s^}m//W%}7S1*V_8/T=P^W+ .?Âg(n '}ʹr麏-5}/+@_c_\.^f5˗/b+1@"/ԯ|/Z:z@~)YOgQ/oTϱx|֘/lzkY↑^mJ,"wrۈ\5w14(^ku+UMTP{D*ag,_iO:^^^Wh~McOR ))+U?9JOAJ=U.U+jTR_OFgRrφ+J*WJy1^Z_u"0 @1P!QA`aq?8jrXqE_N<81zl'pqk*(Y?=8N888$u>V7ABpOywz8wĢ+(:\qqqqqqqqqqb>#qOq=j(GqǁI>88'{A@ABu }f36HL j$H$ q; 0%B_@`o5 CG8A6|%rG . $xAP7Kv  %C$B@_0hΎ84A=C=ql7c4f2;~ؕ pji*Pyb& RfFߎ|%B_`y}ZR>c=q6~9~HdxP@6lG1G# G#{|zO8E.6F6Lxr=s+%B_h; Q.q<{h7/88<#ˁMT%t =G`{n>JqqPyx:I!.TN cw~NsRu@]d{BĿ~ o[3ʎ zw|j%B_<8G0OH: PgpTN‡B9s \"<) vP<.>_O B=z2.53Gt(0q q38BzI_7̢EY>RGnnģPPa(΢^ X=ևaE؍HOowlMKcpEA9>jE(q"Gy7(ȈH@X81ТܛK,yy@?0QWi}y% '݄?ջ8{;&]g$*#Mb:ΨhH&lFNʳi~hhgj㏨j 0 G]l4X(|،O8-ǵ<ڈ'xhʀ!6!Z)pp]cc(dT¯BD D$Xuj HC |<ɰ ?q<Ӹ E**CQ4Z T ~A@2r7XB4𨢄>#`*?q栭|^2ϕĭn+FNⲴ=!j|qE@=<Q=cAꑐ?6WORfV] -z((Gh(?jUg5TEb@0 gxEaEeZu=ZpQE~R'C̘)JtQd@?"/;H/cE؁gƁj?PpZBUӕ%8xBO *(0=C@]*-·Ȣ`8c@gXESCr(>\n a(bzc@9)V"/H#SQ<DV Cc-qoyx>yn7k8L6:\wQNF)y0P#9[.:S8GH#6bnO's8|P`?ԕx55>ZVh4 E).q(4$ZqIkbOw 1K9d; R~ rDy \@64 gb>!eajM_8 'a/iaMgɠyx!a2MYз<\#4h$H,d&y "E\z\ !!RςBv? $Es: CiF9~W8#813C+\#A C;Mƍ"dp(d%OWch7\#@cb:b"VD9NZ+ۉY|^ !$GPb!dg%pWbuP|Z|%j+'N.%lO!GnZ [vIyQj(_C+Am;H,N WO& .UuCEHI=Ƕ\` ?{p@EQE)E7+pCaECY@^}Rr!!\Fd{ЅQh3qeTP`|GRԀaH<+yQR-X%s?yD7Y4n|qXBZ>EX&y}qt6+8.#V0C*E:xQj'HָT0A9'8ddHjyn;Oxƕ@8*TC8?ǛyH5M&!+G_$ Nݏf @B?"6*+*aEh}CI G(dFV Hp@r @7zE?5&ƇԻɠЄL#  ETC[ ø(1, IDjF0/?h;Um;R{hН{C4B, [CYC{ O*pp3B(E1h\3)j5@U*(rQEGC$.#}T>iQWjuU?!+fi ˏ[zLЈiW "QEj<P 5'{fFf.@+V#ŠqǣeEQR0D!lJƇ*(*.";tJQPD2Ènj?ZD}jG("-P1 2J8 Gȟ?ƣ(p?O@0??'b1 {pЄ%=9["!3CBrB&1 eT+<"?!D" QEYpVDF8CǃQECE?dAr?"HJ*v '0gPw0\!8ѢH CBGPB&D;$H5~!'QEZ/wAp&QF UG ؑ??=OY;b:K+DS!=%ê@آp 0=*j4!‡/,T"( uPln_ P@n"zK DqǢEY!%c 7FĴphJЈpdhOl €aaǰ4GbhlX.HLjN4l ZA OG͋ja!#CcF3ɣb$H}ʊD 848b$H"D,X"D$M83>1V #APQEQE({##U%TKk|$Qaǃ3P+J2#0FHq*boq?`Crx*2q¿@AZ:(7}˔c<#✃D_qFAǒX!qt 00.;(Y2<#thј~eCq( QE\qqq\q({(pJO`Ԣ7)'8>7p$H"D&G<s5xqf3c1f4hѣF4n!χ } >PCa p=b<qqNqP4|A7uk@X@%|0\@ڗN p`0\/$7eC(f#Vvً=L *VVowyrx1z K#9> GGO}}yeWA.?!>4@e`XݢP#rgu"V%ۢt._r@ %O+h|yFO,^K~#R=b}߈ ݫ>9V`u,!eo-|,̷̷̷̷o2eKz--->>>)SħOr%%%%%e%"WIẓ+.\j5Ĭu{N_p-P;*My|&+Alw.zEdWoxw2}` AWP0W m~z\YIJU>ygPv7-Ŷߋ 6;oP7'5f=ãp8b*N* Z~[Di~jQx%%;@)zpgReG%t6O3 3Ϸ>|{O)O)O/JS*[--AT=?C=~)K|KxyYG*ȕm?5,)N㧄!C(9s%t*ҽn7zBb#:.z'ܵp#1ySbF`AT@ :=2e8䈪 ڀ}WTThOV[1[:/Yjum_ *'\îyG/_ Id%4iIGeJEDtWDsr6K-F;n\"gy\N-T uBVrsr9(IS;,/kAMK&68z'BrY:@UvJO.z_<.lqB]ɝ9bDD:}+._G&z%*/cynt:UmˤOg9>JӺ?FzG Lg|XQ.+%mR%}%6sOK6oA_m}\?ۦog.8b#$Io/r3=']L68JyG+يN-)(ΰ5x)6<Hc=dTĴO _'+fw]H:&=F\0h{p6Dh롎Ap[L pY-->Ғ%:*M"a_, ],7 {=PmE=^E=}p x߃#fcOtVİٿl_s\SLJ]p=7ycw:&6S rlKJfdJ @`oc@c\}/'E'D[?WWSS [2nAS6 ~m~z5cDTC~ PGC9 zDy'T8xQZr{@o1;dvm웕j񺨨Cx;A`Gf ;2FcENUxu^"޼FgI{=cK'l Lu`y ;6ħkmEn ່w x$nY4A?18}|}D^^êܧ Z/lrt.[h0DW>CgSz+DL,Ɓ :Xk}e%z PRzwkVqWCpcL'/꾏x yK-m>ڊCgQ ٨;d}\;c@nP [ʧ1|YIgT P=Q<#*ٙ.:k\3 pXk醣f~(($0rs$ tɭtozET^- ۣt[SިW Cdlo( :b{Cɀ0kɗ*VU9CQh[78uNzoQj-N5R%叁QW*Xo:-MÓ"Ydo7^עܹ;p,ѾCCS'qx{/DQib[cAFBw3pfp]vӟP]n}~:|;BͰv+XS]<[mU]z&%^AoAv/V6< Yyr>lgC8qެ؊yr?!=z:Q_.eV\}TJie, xjS : 643Qu'Qm.ar]+Qg@"v uVmsjvYı6PZ߂_z#a{V9zNƧ ]y G[ b-Q_A|k[ jwG'K)Wgx4Ќn3nQh)t8[o_Fv;T\}֊T}1^,oqGhxSs%-6DLୋzи}cq؊ޗ8ÏWƋ]\jW@WC ŷv M;tR{d{GjYQᭉe1)N;0Km Xط墳coI>}-r3~PwQ䳡zZmk 3i*v݆E,lv zH;v%JT͡u] :\Ft}$sZ%[^e垱tT2COb>)G/.η5PٍtD{/黼m97=]{-r H`WE[c8g]T3pUl߄s ePQ=ezɰ-]<#ٜK)+ggIBs}mK"S[}m}فmh$-xVyƸ 3/ci;n_FAφYR}eN"սz.j#x|t)ظe~f`߾p+EC1Wr U]Ne2hju̧X6fCɂ 'koDyCNk,<؁=dYګNHp.祏?XALC K f WTżrK 5r",dطھϚ<hrnWDbĆ6,)+>̡N%{1=^!#2%|6Nvոr<%`us(<:\5p=6'Ur*lƎ][pm˹</xk&wU$Tq--[xTl=`^6.Ipyou]K_E;V%ii)wt|;=to PGI-;1Wh\c=%,vpLQƊ:nxy ;Wg pc+rꕰPCz[uմ{100zG6 l:ppNE离nهrv%b⌟ Y^!LAb=}6㉜N~i~G讒ѳܴ_j\5Mi:vh.!ݣ]{"],F 54Abw4ڵ8g)"=l-!>ګh{;UnN<ބ:'&x ,s2Vۗ.^2<( 叁rwK]nN{*}h4y\_fL׳GkIv bӗgAvv:'EضEkzWLPG6xy%YY1._ql:DQIž]@Y_i^7dh^ѿ n˗{:/Z-7Dez=*!EdgũRqS'ދ}`:= zq\@3<_Z.VX; (7.Y.zN#GIIiONeJ-)/}uAm@|Ed!fܺչ}WV^HcV﩮g"8w=1C\tn{P X5r-,/+̧E\às;*R}:'}jV=<rUTrN6L(e^z7v(e{}E9V*uE|4Z:' 9qթR2w%(GZgߍpREl ҾtEz#M͢%H(D1l_cڸc[zXrѩR *qvAhOl}_6WÎrmTW n\]l (!+)1--->%RЯrQ^z׳u: ;o{\m17`M@qlV†c־_5tBiDZZ}e%<(f>3?[oo[1jy-&7iJyƁoTq_R]:r;|MA*Sz+нh.:)W ض\= @J8^'WpٵR^̟Qp?;}}%>2ޟa{feǽ>BPf`{TpEm}@ٓMˢT="èO'sʦږV8ώ#SxNCzߓ{h[[qb6.v9ȸ@mKH1~4V0<=2YXMG 0M>3}  8*cTH/{Zz:hRYo!'£% `QSѭqT2>(>:)mCȀ{7:l6ԧ;7Y {R=(tո<v짙K^0߽mL5UG1Q^諕޺w# <#_:{m,nt'.^rn[X ,΋wwbTJЪ1G&H1o@\.tKP;́'m e4`o_}*s,ymx;3}W +=$ bpj;^ipe.EKsth=sSINd89bTJiاd+ {mkU<M : e:xt/Q}-Q'?plrb|l]DtHZ8*pfVkza9wS[İ)V}%{5^}u_5{o[->:Y̚Q}řܧ.zð9۹[_{}tL b[B3~KӋ49SB{;;&)Wݥ-C&󇉌B1r%N 亾gqzhzh>[ض+a}K|KۼS*{WoQ3)_4q9bo.I3} t4ޢ1On UE` ɎRLlo$c-U{F$_#@+G,O.a駍2juRR}e`|\MvWzf}Ebn1܇t(v oiy,i ocGlQ-aN_C^E abnEv*sH>eKGop{mx?Ӡ*gee#_ ?>Or u]rⶫܨzc`px/P!A;%bb[2̼YV\ƹ? S{g#5-j&9A@>-Q7rbਹ(@T V9_[h)S.ᾋV.:c\J9ZR^Mj bΙEcj-C^iCr@֣HW;٩Z#c{]vS=;rSb v=ց|x}[˶C횸7ZQ N1оx:&=sj"1/-[}eeeeUJq'ޡVFK"SD=@Kvkoo%y:ܵ 4`oɽ_HNdqo-`ryĮ+b{?}XƃNw^rf](EФƮ=ǝw\^X,P&^Kxy+zaqmC1aBWE5u]Ossͼ` Tp s YbQA/U. @a`]U----qq.8y63O(}DmM9 YO-S/WhO23 rXo 5)DUKؗQ+E17whjjfT5}w UNy#9e; hKۖT[Rv*/p68[,Q*W:8?\F&@k}3O}\:WhNl~ TCn[ӁSe9&Ʀ#\B&-âqбGRV[euJ. pʞ_`>XOgcۃ1D|ߨQXpwc'f w~0Q^4Tϯ9֥laɪ{mI؀p9f"fb}L@ x++3_-Gg}hT.Z. ڴU@}].׷xxLǒ֮[Wy+̽' P/r3> œ=j2pfQv41#x "SS΃GOJe%:[uaV_fp Z!Ubzh# r ;3^eyy{^|9gw.g(JoīOo1 sۙ!!/@VjcLD;t> kwY~ AAb3E4efEƉ9I#P5\'\l2jcUT} S ac-.\1{ھÉܯ|2is-rl; O*JjỌ5ؿ)җƂJTG^<#ܹ·D k]_3x86Yg(wA@yNIa=;V%7>gW+XgG.2x"({^ ( ^MHOr2rh-ѮǞ>v0"u`=\C.ph^p> 'v#eVBiO Υ*Y)).mcw~cCE55 CW_H4\\O=5h@䭂{fH~n"dz\Y]זe^o8k׹3o< rEL"8K0mrUDHf(h#v]lZx;:kn\`QANI2p~pN# AkG/wb#2T`h,;UZ 64x--* \|[բK8˼ [9Dwc'E;~ c?+7P$qh L@v"z%s~7 "d90Nc<TJyf"ıbN?Wg2׾90L,s>)=6G{٥؍tCgk#>_Æ.+~O(-Ћ(qB{DO,$=FxYYy%H""; à.Mw[=ЪհGvߝ9)u>o2x׹vfW.GQ:{a8Ez^d [燢Fw#gT{I{P'QwrXeZgOC=O'rHMSzݖA.%͹wpcO廒 9уPoG[8X%HSvvki|(`݈9t9"F5{ǡ,vؗ0/D6 A=jTTZ%;oo12QZk'ܿù'L 3jT#z2KT{LdACvt hkJ+w0&5)>X9 ?)#b8 9fZ0 b[K`-Zuv+!xedP `^YfeP-h@fp>b+JuLj8]C֧Q&e{Q lccP 4:Vs0}iX,X):Z =_0x9Km- s#D!g85;8Un飘 gUGPs܉M9"ZiuűC,|å^"%Vhܗ#򙞋;N p39"<=a\qXwg0>" ܾ3((%T'y~Y,0x?Pcb< 06h(6#}9%H@wyv+0O7ޔ/>ewӼ+;/gVpB8q쿹_"n"ѽE=ha}L7S9r/TE=l {oP[ 7ǍeGO5>'YV><@GMy+i816rp?J;O8k?+yT;~SԿnܱysǽ"Yڏe(S2e vg{_~v3, ;e-E򷩯<7NTPOS?OSה]Nȯ.\pw-=?OOTI 3Ag{?kb;'z`[gVgVgV9QLS~6@~[syCRù+$*O ~6Xr2sԲeJTH|GQo%C.qc(9'+8n$s3?NS55qFT)/N|&W)>A}Uyv3\ͥ 9ݢg[,]_ܿ҂Y/zw(pwI߳AլY9?^5_B)bVe&9y'0Fr|70h#6Bj=nދwS'l4 ũkn 62k fZ A{geKj۽R!2$Ҷ@ppB'rX1Ixe4fxMp?KN^H8v 7rnzÓEjtn %ɉD/KEũk"Ի--.Y.!UCJd7}cs KْZC[}\퀶]ao2;T?B?{_3SIZ. ]6m0fS&qm5ZsD-A{R8uF_G:Wqg`ܭ$˷`qf_9Xa@}yҧ\3^pߒ[+'RYmN'o<Id"&4sQh(Ky3RFCq"a婔h&@}*oK}*WDA;m2>tW}&ZֆtZzv6mJ;nnuN3?O_Epf|u ى[] uyѪJf  p)'tj"yoNDqT]BT43Jp~ c~/ȫ_4+%:;)!v=&兰of[ nhVmr3NE3&S&W:b 8vT3޽oCPoJ3JƇol00_"<:'>p Uz0"tsJ.^\AwH([e]rKyO?02t!:L%rPL$j)hG?VW,l~ A;B3 TEwuLGKmm;8Ssgbk0Z=gnQ P9wrIJtp v^qw"Ua9:vV/ZAKz;SroFbE}=?ַqEFDLJ:TZ<g7hbe3(|2%KW -DOTOC>4f }1q[ӍvLX&ӱPڂsW\//ٗf{^}+ -ÖP{5`O'/cwArϵ-)28/0+?I7f\6VW1AzCK[>۪o>h pk|rÁWfz O#,#^^Gq)o*qJ|Je1yW̯YOQQSĤYyyiiꞩꞩꞩꞩꞩꞩ2KhhQTBJx'SKy4RGe:N SDaWop=/g{~u\HjN}@Br,"<cEc/gK0懌Ea!w?d_}gL(?c5x[D?.U2p?Q2#0}E+U)(eꕿќP/.ϳABe{yLb}ܜTJzS PG£=TϴQT^pn 톌ᝯ̰?DS--->Ғ%} qa_ U.xgOA?LN^{'&_C<DZO?'R=+_?8?e3tr܊N r*pW2?O?O?OL~.[eeeeeeeaCf`rW3\x`D;8wG&:zpVľ;q08gmZ:2pW2m@r~Od?N?xOL]PX_OA@O~O'cb zuKAg t[{=2*:5K߉n`Lzq1̩W?2kGМ3옦v~ڈV.)"Զ> ,%5:#;q_Hq{uքJiߖ}>%;äjt93šv%ĭL& R'r^'qg}c"1~$d~~/S1.%|+}{ uk_&6Ხ_js0肼@uʞ9:෤0Bϸ@ Q+ffpS^4Ti-!Ω :Wrhä'<@ u <@ náo. Q·;:MEw JySk51vJDPbSڝ#cW&456,ɝ\\@tO \A3Cp^%9?;L߃bS|gqm饜ĭVGI¬w#1gu|=˞3JfoqhrbeoTuv}C{um1K=ʂ}@n'!]ԻZ3W-JezUq+fnL z;;ŷT^:7+ Diww.6ؔ1|:K2re˗. n wpXe-X*<ȔݴG@:.u;uVtwV۾" IqXDFk6 6޵]# <߱hV-Ʊ܂w_P,K<2222e S,щNԮmv׎к巶|gT A'bXE4-;GT`];GS-E=o- ._X8N6< 0G-'F%h/ۖV_jxAÚD/IuNG.ۣR;kUwcn1$WZ F;a/p^2kL@JF˗9N7+in=/DO+TۖTX?,>6~8O̾?E=ڴo]]NDF _[GJa)DF>9?=W1^t6Wj8rN)vҥ|RA|:Kۆ[x6YZ`?[lᗷ>T(f) K:0@8t}m*7Upս1^(;ڕ,/ _Z jH ]OWcdCz '0yJ/j^bs[W 0~̗ev}IW-;~ǩK֓?́1*I־ 9@@c@g9?i?D)%K?6?(xJ=!߬s1pp^ aBNcw1}3u)J?OgCҤ 83Mع%w-X'ט'n õj-b{]ouƉqYDDŽcW*v.\Ae}y_eXٙx,i=`3ִ'0߁}q=DLZb_2 K['2ϴƟyOcmAZ3 Јel%4_Z]g3x^Xg?~uχվUx߆y=d1/"t%X?P HQ(&#׳'P-lJ;T},|lzdtF3 O4޶3c}*JvkQ 3RyY =Oܳ)Yul%q26"32ޞabv&V(eOdDsطC"}*< P0,.+x[~b;GDKD0Fw= ䷗Ur +`X }ee]Ư D N/)G[a-.YUfE,n8dx/Q|~Q\s+xUǷ[-_B1weýqDW+a]l[\KOb-r"Vdtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/000077500000000000000000000000001325435343100262375ustar00rootroot00000000000000dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_01.png000066400000000000000000000002301325435343100307620ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX nH@ GIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_02.png000066400000000000000000000010441325435343100307670ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXӱnS1g榁$BBjAdd`,,aeE<ba``CB,Juh * Mlnob;G8 3zME`F*c_$޿gn_ς~ Gw PWF十J%I$I$Igр'IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_04.png000066400000000000000000000011011325435343100307630ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXҿkay]JmKQ+iEPAA W7q]tslTEk%$^yS2Z|lXPxHvtDnq!Uc/UjDUumu0|KTn__@~.'V9:C-CÒA4b U{[?5k(pWY[D&E )xE$",XHqs۝榤߯ }!jG]2Zޡj !ކVȒ@>nW.ݟ86XQ4An@ƑQ@,Ȳ*B"JீOpG^O_ 8`39m㙧w/.~}X}dř~򧭯\P( BP=>_$IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_05.png000066400000000000000000000011421325435343100307710ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXҽkQsnMƚ(HAh)qAE'I .NA*Ab1E,7<Cl:2 XȊh3F}G|p48,L)냩$ÔAB$B@uon_]. sB.p3IRS$BI/;4_#E&QH"i! @Py+;ѧʃÕ?+P+[TDrP 7ڀ!LcTLp5Z4Q%/T^7Z޽hՓ1 8`O& {L1Lh4!m$]k J_3F?Mެμ-M9k$w:g֌mxx(p[:&=qxrLx:EӉT}h Ow K<6#^bX,g }dIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_06.png000066400000000000000000000011471325435343100307770ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXпKUay{^M QA FFTdAM PC P5TK PFfMB{Ϗ$Mf:y1Ԡg8x6eo5?%>btAo)->%O$(qfҌ(rZ:XWwEM;ʮ26#tP Ny;RYjh<3z׼*^bLGdNa.EAYoe ZBٸ9:bJGF'T>UIօp؈ RemE5x(^W[Bgw`9gL78hq XenOv]p^cT_gݛJE\@OW~W/R'CZz+# #pfS&C%|q}U&2[05F͌+>]Vr\.rkWƷcIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_07.png000066400000000000000000000012101325435343100307670ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf IDATXKTQsνڽ r ^E@Z lhʂmE2]( "]iRޗs6E^Qgu?CX5PL"J`$54|Q`*lA (1q]S:dV!.(2KP^|"H8 ^$YP&?ޒx=Wpeױݔx5Xc \迍zų}#L$7=Oj i?F=RM Wd\kED[B1U@XU,PE?83 0P[j󳲲;A٫IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_10.png000066400000000000000000000011501325435343100307640ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXջjTQs JPA'!DDlBR)^Q[' ( " A"633{H˜&׋n^Ovu~$muIb]떯,̮>Hh5W0 \97{T:VMX'2iw5ez,8X2#9fV;kE]wSci4TDŽ*TpaH ϟ}jyeb S+ڟwmm9l9`en)m4ѩJ>t[  Ñ@eXn4u6RUx`|dݩ BGO ִl4uA) @_sLȸ%#0BvY|Txkʅ3|)x9q=%}^zG ˼[iIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_11.png000066400000000000000000000011251325435343100307670ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXAkAݚ6+ZED(%s=x?EOz/-7QA)p~4תn>»O Wsrw=to`IK'V 6&+;F/VKs%q*T(aqkr UuSКN-LN؉4Qh x",MYcsCE"@Z%p&"9 kD H"ټc[#ek*BYFZ jɇ_-ҘwKVNlᒄJh._"n&"\ZqK+%|q溨aYG]ͻH"gjgz`լaTʞ@dDs0EUl}JB XМO@\N :8R Lъ\"e7K)G͠7A|? 2 /)F*Fn7@((FV"?lYŝjeK/Nyc/7йd j)Ё/q|ڕSngFzi#sIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_14.png000066400000000000000000000011211325435343100307660ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX?kA73{w{k-y ل FD!xhlr<" oӦMI| ڟYjp QVnqh Bvs_c&gOp4>bi;/vlc 77x`}85rfqЈpIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_15.png000066400000000000000000000011401325435343100307700ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX햽kSQƟs|ަIRlQA*8OA7U."8( ZG478 7}8f̘1?Ciw` 6> 1 ;$| tcq+4d^J*?NU=Ov!W`܍!iN}zqMT_ 6A: eE0P&PUD) %$ts KE y$.x}ZU ^lyCMKg X+l8SiB88Ol(\!d/ps1.>`+ꀷ+?S kxP5 h kVpg"%d*z`95([q>W$zL&p!y4I_+Y 쾺6)hS#j(eׁfw;QV |]pW~Ūa/IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_16.png000066400000000000000000000011711325435343100307750ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX햽kSQƟ{Mn̍7ܪH*v][:8;8CMAPZ暛s^"Br(- UkBe[WAPP 6"HT;{ZEm%%*6,,au/cSб瘆 ϯKK4k㙿NIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_18.png000066400000000000000000000011741325435343100310020ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=hSQ{IiڤJ4) EBZٿ.瀃8[H']\up(ںդ ۛ{T(.MtssLkf"jܨ42<CF~qd2t+ E~MuhPr!IpEgrDAɐJ5:(˜E\b֖O^NF#.8M n6IQ={@E8af5'+cK n7u>nT`a þJ9d \a$4XhtQ]zs(p+dB2 iVʧU[wz;'TMGѬ ag ƳKҼ3 +(PnJ 6k| D,l$qǘb;$4xiխZD05GkU֔~e;(=B$+͢6ݷg-]:mIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_19.png000066400000000000000000000011451325435343100310010ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXбka]Kj$6Hk!JkS- NnE(.Ep Xpu)HA[ Rr j<_^ H$D"2.X!-MÊ98j|~;ٜ똁t2Vy-$QmP6 80c׸)} `EpR"N-egdawu6MrO7g2ꨔ Y ]#~Ek ߾RœvIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_20.png000066400000000000000000000011201325435343100307620ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX?kAxw'1*"`VQ !*Nlŀ V$F 4&1wݙy"^Э)}f Oyr}z[G*c'էPW21>p՜qR50PƦqf 0CzuoO)0Z{ۊon`zrSh9' aI^=ϗqW{rX C$H-\m=/㲭hWFhU^eaPV62{ .gIwSU/p0ޘ@ ([%)Lgҫ86~Y`p"k["P>@H%ooZyο6,ȃP g9 D:}1m3 ]=xZa|rdRL[MmWݾAh _XAIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_21.png000066400000000000000000000011231325435343100307660ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=kTAsfv޸ hD?P; ZHk!v&"J(5D&uݻsg_ysf x<W\ n -鍚3@1|6mXP8-?z;)W(f"$08k8u$R"o tȱ IݻV]r Lvp,q%TATHqK i.M$vU*jv, @jJʬBmBhjctP3+3-mX~[@_]6.g0 ٙ!JIdR't#q? W .(22ƈi% (4EZLV>u?X ;{"EYH@佀[Mjiu~oŲ^.:_+ mm.IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_22.png000066400000000000000000000011251325435343100307710ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=kTAsνwwe$l U XIVXXA؈E6FH$l֐f~ D%&y 8p8 A}J7!)vWt1׾Ivߛ|qSt\9U5V R*$_s4.i lm=Boˌi(`e-6۝T qlQ j:\ X{{yN3Sq* ][*CAOjDz6^S ؐ3J2JP'h$0"ϯxcXgqɛFͧLA&.+Qg>TZ}Y-*+s=Vyt#D8ICh! ȲZF.1=E7+.^LCE%RL𴢐"\8ɺib׆ 6f=7IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_23.png000066400000000000000000000011011325435343100307640ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXjSQ='71m"J) G:*E'>@#ǂC8q"8u̩`_+%$ޛޜXc2pƛl<<yehA{f¤7g+?lDW+,~K0< ,h4le[ͪ-8esQ ZJ?11b-82b*.X D "/^wZ q7aIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_24.png000066400000000000000000000011041325435343100307700ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXҽnAsfv łQK,!AA4(RQ"vx"H$l-ۻsh+oqqqq3N. #].9poӯWcfmj^s?t|s7&V3Y ;OM,*b{P?ōx}ؓ^LwWV)immϦTA{:֢p[/Fb-м)i|YTr_%3+P*(!9)e0ɤ9ǚ9ob <%uE#H"@tD0a@&ᗡOtw>ONy Vo[^ |Q#jIp D pl3Ql='x_?1={bITG5Oчf83iHZ K~IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_25.png000066400000000000000000000011141325435343100307720ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXҽkSa96iM6";AQ\DA?$\AEQ Rf*Z;-"+fBmc+le_Oj8x^cIZ~:q(9;{h%04s{6f;9^0Q3L~DAww}fi>RΪ^TK GauC6h]А[왿+PFuX\HeB S 'D1vrF-rZ&֬ ek'wcogUÙ,N$ g=UKgHIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_26.png000066400000000000000000000011401325435343100307720ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX?hSQ߹$M5U:TD "v * N8)qTWup(sRv}_HRT*Jw;})oˢc9jG=oCޯAue;hqE#̏B`EAΓǂ1\[%,\pp|-=̕oV!@/h Ce|rF<f:ay+'4Un& jEƇ o@L@ &#3~tl Ssł/VxJԔ|gn )T0T!Abmŵ\KWط+ NhWJdGUB%%4Ls /7FR-IP8[h![NHl;h{X|789]N:6,7ŌZЂT4vpa o|"l[XIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_27.png000066400000000000000000000011461325435343100310010ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=hA $'J?$Q A;J)XX2 v`%J 9(DPx1ə^f>+FI> ߼0T*JR&Cۙ aIq|D)"7uw@ad F8k<+/+U8\=UqW7 xuÞ>XVƁbFZ-o$ȟw272f~$nu;o+#%,fT^FY~*}V+r(WUUR Bpjª70y?&tr8KS[R8FO ]!Nq1g٩Ye >#"'f͊ 2_/+TR]%[$HFUuuˡ~-(K U֧kxF=oQUn~O2IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_30.png000066400000000000000000000012011325435343100307630ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXMkQsdm**HB҅ ? ?@B7APV7]I( *.T?(*6& )tJA\j9pRRRRRRRRؗ^0A+*Th,+|Q{T˯m2I On”#p1$p)NNcx0[۳urϯ:xOK}Nf knh]F :G`]&$|1c|IRA@8=m)-5,s.?>Y@p]?~ R<IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_31.png000066400000000000000000000011611325435343100307710ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=hAofno/sA- !`r_B665vilE4Fj m$]~f泐VkO5|2 򟡽wCL2Z;!%& &Frtg Yrv̦Ll;$\%‘ 5x33QrluZ) pWhSx*+A |w-qG1,'6Zܴ̏I8SW]n/czFDS OLPDQ|tT>0߉ ux5[75^{D%fU$W/~f S |qJItQa?S}! СQ+48@w,k]^Ò\wcGo9EeAƚV^.2FNkCY"d j+h4/O`ˌJf# #s0x?GVIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_32.png000066400000000000000000000011721325435343100307740ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX햿kAǿG.&x5FBLJ-%D Q; 6 FDD4 )rDoγE`nyE1MQrԖVŽx(9kEKYNL c&4qQhZd٣Ȩ@'BWMdGYτC>Fj` -"]H̵#o\UQ g*PVX/z@li1lHYfcO?zaնq4O/KG #̡F'v{»'f as6cNFǛ+` };Kn2a)Z-Jޗ7^km=KugĘ5׷fw$}ʬ J#c#2c{-^5@Py^/Jl(P2s?2ǹ|\qIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_33.png000066400000000000000000000011251325435343100307730ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX햿OAǿՅ#r'Q9 xb4h-4[@ag RlX,^d98Pvwf+n 0ffppgƦO\bJ@Coζ٪@ɑCx0fgoU@ bU@kE@Y h$@]+-!R *: )TKYJ+{0"{s[rcހ0jzs" 즒(1! DUo`a4}4.Ov]k2U=9f^qw/8=6)~x!Ә=VcPJ{:[֡YK,0Q?kA:rq7{wSpw6BѸbc%VxqӞ FoN=}Wcf|h6ӱf_ w0P (r=U촐w˿3kIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_34.png000066400000000000000000000011411325435343100307720ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX1kA;sw A1S.7QEUH:X04WZ+)>V|O,w4@b#LDy+`K446b~yqNTUK7fƩg@foTWsKcdj$kXoYJfhVIoįޘ+fleJ(jAWľd?d\DhMצb_o6;a+N;3'(whkة'wbJ{5=-R"kϻp,ly}\ᄍIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_35.png000066400000000000000000000011261325435343100307760ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=kasޏi0b4.t?p(8:MDZE)%I&y "yp9<73fGN“pނF{+5q͎jqJ@秽cF(SNMHPh uH>L Ms~tAD`l77[֢4*X!lFv>X:x AcFo%!Qo00Dazyc ĩVL{n$TL&qPr6*RWqc8a oڡJ7\lZjM#977,;YG"RΤ2{% &c~xY,gje-Ƿ[#_W6KC˚,p|!h1 +QJ)>\Y#>cZKJDJ-Oo5u?w,7Và9&/WfIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_36.png000066400000000000000000000011161325435343100307760ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX1kSQs{MTSk-U[;;"IgG7 A\ BMAAĔ$/y{8..[x>.&L#f,}=mƍ$\+bpҼVמM@o)FRTE*/-dS $fVl3` MF=㢡*@[#?*IpeG>W@Ѱ3iy9H ufn?9͐Z@!_AeTYS"+zGũ}5&bK".y{h|w?SǖĪ{Kw\ K'ppuodKUbP< w0˅z*s$fXNsdN5ˇJ */29_ҔCz;o ,]c\#+q5 \Lu1cgd8XDy3Ճ(G^.Ԥ^kr2$}(PLXXՇ@WR) ,%mNʟ> %):+\&ۭ^*_?xb!^P6g׽{!R"scptx#R,N9ow,X:& eﹷon'I?!NLyF\PikFϫHPN7HFM"Ү 1 #4{;ѻEƌL*7/e![q̘Bg*|FIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_38.png000066400000000000000000000011351325435343100310010ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX핽nSAF^vH, $)B4$(<%@t$ @JJCB"ȖOB{ݡRQmSM”)Ww_zfh:onŞcP^rYn{5 TL.ŠH)qƨ7B)i$* YG d+mC[߽w^0PՊaPе" *L{hP-B.< 3'$X }#RA[[,ۑֻs-ʳ̍N8Ƌ}ڥ_͗+AN!Wgi?NUbS2-)VvIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_39.png000066400000000000000000000011451325435343100310030ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX픽kSasMLr%C1`.J+NZAAD"UtPXSb#MLkb>{{RNK}y?3fq}_&.LW el%3UW䮥'0{<_N“4rL_w;G '\I^ U&5ȴ 7 V"ado?%/p(qWcОiĿ I磥YGΣe:j|x8) 5#LPqf/_޿[J&<HܹV>ͪ0aЉVũNEL|ߛ4Q`h |6x^&f>:%M}ENjS7tnWgt|6dO79030e#N~fPDLn{7`~To+zʣZ\=0f-`VY\ي/'pKpKs쫚/p)+Ҋ3`h)I+"\PDZ(5/;.=l#4e[:jk ާA^4)0wiTd Y]sr55AQ㌧?9L`䀠-֭wO^k!vf24g/#dQ~LPDO[ TP'y\8CUbkcع vBUE csJϩFħn!s жŮ); )6`|p`iv&jS?0w f6eIߋ7?)9Z'1eʔ=w4sIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_42.png000066400000000000000000000011731325435343100307760ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX;OTAs޻AXP1F1Ą; 51Zl5`06ۑXj#F]sXMJٯiw^wyjBd0]ߦfdI }D?PN}E\lQ G:.qkg990 xNb-+0&G"-d"v!6bi:q|fj{٨\#fa,;Ss'Tmf+F+^O,?(0 2ow}u>#އdVX3mnc$FAVĦ~Beh9]am^=f""}ZԢ9 0(c\.V̬iPBSMZscӪ7zH|w 46։){cD+Tlx4j, [qKkfӌ!)}z(jv^'գqZa=z8%IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_43.png000066400000000000000000000012151325435343100307740ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXMKTQuQ˨DMd DТݬ[i&6A:0ehZ4wsJw5p6=PM,nhb9o̵bO&S+m|"h'`_Թ2Ruq9041ץC޽( Ai ȸ'(0 =Z\ B7}`:)eC_Or,´u3cfNrxieh+.pѩ.Ou']"= d 2Rdev}8IT9% +]yI|ἢˡWa"CTyrP'үЌUl։8?T([ڶ(CKHLhZ5MT"~3M?fgUkI6H7\R~wH7 u֌͖7H=  R ]wuT-1t`:t "TԒ"IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_44.png000066400000000000000000000012221325435343100307730ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX햿ka?}kERn'7L.uABEphE*&i6.{߯ZXyp;ׅŘ9IV*h\I<@=ݶI9(. 1 U(ggm1n ,^&^W9_ѽ\ S9;6gfqmO@-pa<J7]SjJQXh+.Ii\.92t ~(5sGb㓚2JxCY۶%MHkmZ=`nYi҂0j@=MK?yCb?At?QL6XY凰,I8iod0a2pկf84L^Hv|?A#4\o`oƊucmw4mZX:-۫?(x@FMqӧ?78jIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_45.png000066400000000000000000000012141325435343100307750ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=kQsf(1 %k b`Yؤ6E0`!E"f|93 q bvl)އ3W1Nl]V3OL!`{<=TĞ6<1!0|i|hKM? e׶bxfΗǜ6cˤ2MSNa %lz`taxjY+ )&@[5C]aƓP:xV:z5 2f,5?ʇ0m *7?} "}GT\^tC,Fِ+OxT@x/l.yJP'䋨RU"߯bw s{f{ѣGѷIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_47.png000066400000000000000000000012341325435343100310010ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX?hSAǿ{y MRTEt$BnUNvEG\: %䢠R6${5yw? -Kxw܏qC랸X\-i{ >Zkr=xҖ|dL7(rc'w'e_L"3pގzjfpDY35Q ݇$p5[E{# cϰ9+W?Ge¢!E45߮Zʖ +*)zr%pmƲ{KUQzz2Aw 'C=d9 <)W9+.# WQ~u+4 d~ssv[oW`~ç7s]k}eDtjTWf>kE$bTiӗn"sSBi0XjXEa1@uBC.=x|}PMp)uG..}ru:E@}et\ $$$$$dp${*IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_48.png000066400000000000000000000012061325435343100310010ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX?hSQ'i D,8UA$HAPgH'')&)jJ@pRix{{!P ǽ{ {b).2H'Ry>`Q!\%-BZW\@pڗ036SDp~U% Xpd5i0p"Gd"Cg[\; 1ϐS"xZv`kZk*{3"BP6jF@Ir.&DjiknyN):CӲy`a]Ps|5֐vup$g8T7rr1˶yj[TkvV #RAsgs&`xu 9X;=sJkJ"}}+K8(C,qfJ9J!^3+"bLL$ fy{hG̬2a94h!W 4M?̅22'%0bG 9/ [ -Z vv`ĢA5$D=-zl7Xod=ys96k$TZ^yX/2/_G/؂WH Hȳ!A+Ze22%(O 3٬`O?,lL3uHekE_بr}y&aQDLevZ~ yTNN[$sӕm2NaIÅPS90ѠIvnRBoUF5jԨޟNIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_52.png000066400000000000000000000012121325435343100307710ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)Azsf IDATX퓽kSQƟۛƄBV*DbAWukqYnVPMh.&MrTG2t{{[:Gi,FႻ&09MF!Q&f Fmtlj{] pl&"leN pZD+~>^,#&[mN+Ehxe |g8ѯG>;uB X!X@MKUzSG3qrrN¬7xJ@W@d*&>D kb]-$ +_\0_?kB&uSÍ==o0Prɗ 3{;jͰ#^*H-*l7S9|kIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_53.png000066400000000000000000000012161325435343100307760ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXMkQs$&UZE#(Z "VQpFbZRqӥ6 ؍R?FN'u-bmC\̳>6AaO)IˡgfAm6M}W/6C$SHB c·:?;{PpIsa)0"`l̍ \{SsZ)<gd+]ŘQC bgyTZÌ\k"KN~*L/5_Dg] vOimߔCĎ.c2#~TW[Uֺ ' 'T|_V/g 4$a `LW=,N%iW6@HHELj\W*HSZG3؍^1Vi2?U'W/)`x"_]ؓ#72c-q;zLLLLLLLO:RdIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_54.png000066400000000000000000000012041325435343100307740ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXKTQs8c/L"_N!QѦ]Bh٢MZmZDEF;0%HhIS8?{-*B#a0[aW#K#Wy w=dw*t='HkNEfq@&nvO`^YZWݎϐ8` 吳mD] dbyI{B㔦" Vy@^Ttv7/pu]q5/)43"V$/IJXVz&OuWk\&oi`dn&Bh>z|'5jrHy%ŪYMZͬ/pLYB*'̰/uOci{G=`k ?°ߨ wjB^-Hp1pPs)=0ˁ|7 nf CCXaiuanmFzr jPgc5+#}@SD"H$,:5IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_55.png000066400000000000000000000012061325435343100307770ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXҿka܏\ClҡbAP.*:s?@qp)b ":Tk&)^M\޼C(-XSrý{`O*elbڴ "HJ5K•tv J,D^ɻOKvW/< P*%LYL!(@=$P Ӻ+abA0 3"F~e'IuSけs>n2k+78Df~Rw4,l++VFތy@:иﮢf;o[gܝ&dCOŏ{uz#n=#e1J/琰͸)7>^ӱoZ(0!*]t;W J .Wg :?n c/#H$Ds?5[&6yIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_56.png000066400000000000000000000011701325435343100310000ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXMkQsΘLICHSU~!NWҝ/p!n.X".ܤ B(8jH&w>qeSq1r}9R=Ur aI D7(j*I~~{>Mxd癋L&O8::V=5pz!A4%! И=30)8 -MhAu!ʳjH`05œ#1Jڹv<>J׽`dcU7D"*(hw"h:o .n5Q!R,pH8ƳDh )p wos,EWs' 3O E_8$@p^Z 墖cJq@`E^o%q *ͬMރs9OuUu~ãyY4|Ln;6\8YQ׽~*YM;ĻƢܸ/?,M`HPrF(e7sg=xU%1tĤ 1gW(B /pʇXj#EOᬏٗD,@ ;ᏏS RY"٩T*JR˩nKIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_58.png000066400000000000000000000011171325435343100310030ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXjQIf:`l h-7".7t+uʅ]wNpo+jPJiHI'L\ͷ>|s+WDq$<Ȭ}a}(':n,FSaXIZ!L H ywc :RśR`V BXP`$5oc<뫇ŀX$Щ }@=ɪ(f&k'6` za(X~h?̮\H$49[CfvRwRMpW-8F۷aPcwN/'GƱ(KGlQI{c %4ƇVO͏ JJ1R8Z}5mLT@<v/Q}-VٷOH='''''''''O7 ,}IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_59.png000066400000000000000000000011171325435343100310040ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATXjAsnUw0qˆ"}7Kd| ;@\(…č?hd&3ӓtW1ĤѸo[ESOS\N L` x`Nn$e> cpzSJE5 O$c5lVCZ<`'2ĈH4 K:$ $Nl > z} X9ߎ3Ā> 0#k8s reމh ڨ0df 1 FNtcךV | m/]!r)qOMVi@KnM@^BsV 9F#ׯlYLpt|: lEsr-p ĉM{4_=<8'e_# ) }C  uмoRRT*JRk?՛C{IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/eLoading/eLoading_60.png000066400000000000000000000010651325435343100307760ustar00rootroot00000000000000PNG  IHDR szz pHYs8"@$zTXtCreatorxsLOJUpL+I-RpMKKM.)AzsfIDATX=kTAFνW|,HBX "Jl'VbcNb'P,jL6̼$.j`f0ɇk6*2Ud0 7q' x3򪳰MkQ*a \!^^{;A7Yh3UV JIA} 447t S+3QTII}pR)nxrz2Y t ;=F'焙 gӱ .sv,)M^ߍƞW6nacV½# ~KWԚE!BL9~{z1w[#á'ƂI%?ooo/Y3sLݘһ/)=mҟ+@[뎧`i\tZ+GY܈ w?*_ Z{IENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/images/loading_indicator.png000066400000000000000000000030101325435343100306660ustar00rootroot00000000000000PNG  IHDR@@`UgAMA a cHRMz&u0`:pQ<bKGD#2IDAThI\U 1I4((BPDDp@AuAp.%W.,"Fq $ND3Nq5w]W5uUuUw!iz?\'wA2A@$ Kw$b{Wް@DR/˄'i!rS/>/ *AEbq|̳$RiJe=ᡅj3T3zW?X墾γ/ Ӗ{QL'J_{Gj!bfe2뛂cV/s{޼>SlRO]- -l X-hYF[ZF~שpW WblH\]McG|+%_#$6V6KvR!9}˼/z[]p'&v9=EA>E*\s[kvuȂ-j \El3=IK➡K/xM wxK16[? 2]%]I䋭~TZiU@FOL;3OJWj͚_mO2~WX:wHPQ/lUYB=5f*i܈/#16:hf}a] R Bj ùݎmR<& ~h)HOt*x8p|-4Ϊ`qvi(c/gyUGlfAE !7a13rZ&#[D抦[g(An1}>cC!\Axٚ׍&|%Exqn4u|Jp Wl@B_ NcWÞiի89P.A7 ?gG4R$,R&ݓbL$_P-afF c\n_ӵ:yۂ#liS;c3ݲ5uMlzU_(cB:7In<8 QMY7!r$' r8]2Qy^IQ8,Q%ʹ*s6{@g9MHgl/_ o?q`su9N0FX(՜lK-zILsJ@35\ o@\0 ^qoȾC.v1(".@(lXtDu᳢9}nzt= KrSTpIENDB`dtkwidget-2.0.7.2/examples/dwidget-examples/collections/indicatortab.cpp000066400000000000000000000120171325435343100264200ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "indicatortab.h" #include "dspinner.h" #include "dpicturesequenceview.h" #include "dlinkbutton.h" #include #include #include DWIDGET_USE_NAMESPACE IndicatorTab::IndicatorTab(QWidget *parent) : QLabel(parent) { setStyleSheet("IndicatorTab{background-color: #252627;}"); auto layout = new QVBoxLayout(this); auto *spinnerLayout = new QHBoxLayout(); auto addSpinner = [ = ](int size, QColor color) { auto spinner = new DSpinner; spinner->setFixedSize(size, size); spinner->setBackgroundColor(color); spinnerLayout->addWidget(spinner); spinner->start(); }; addSpinner(16, Qt::transparent); addSpinner(16, Qt::blue); addSpinner(32, Qt::green); addSpinner(32, Qt::yellow); addSpinner(64, Qt::white); addSpinner(64, Qt::black); spinnerLayout->addStretch(); auto *loadingContainerLayout = new QHBoxLayout(); DLoadingIndicator *loadingIndicator = new DLoadingIndicator(this); loadingIndicator->setImageSource(QPixmap(":/images/loading_indicator.png")); loadingIndicator->setLoading(true); loadingIndicator->setAniDuration(2000); loadingIndicator->setAniEasingCurve(QEasingCurve::OutInCubic); DLoadingIndicator *loadingIndicator2 = new DLoadingIndicator(this); QLabel *label = new QLabel; label->setPixmap(QPixmap(":/images/reload_normal.png")); label->setAttribute(Qt::WA_TranslucentBackground); loadingIndicator2->setFixedSize(label->sizeHint()); loadingIndicator2->setWidgetSource(label); loadingIndicator2->setSmooth(true); loadingIndicator2->setLoading(true); loadingContainerLayout->addWidget(loadingIndicator); loadingContainerLayout->addWidget(loadingIndicator2); loadingContainerLayout->addStretch(); QStringList seq; for (int i(1); i != 91; ++i) { seq.append(QString(":/images/Spinner/Spinner%1.png").arg(i, 2, 10, QChar('0'))); } QStringList seq2; for (int i(1); i != 91; ++i) { seq2.append(QString(":/images/eLoading/eLoading_%1.png").arg(i, 2, 10, QChar('0'))); } DPictureSequenceView *seqView = new DPictureSequenceView(this); seqView->setPictureSequence(":/images/Spinner/Spinner%1.png", QPair(1, 91), 2); seqView->setFixedSize(50, 50); seqView->setSpeed(20); DPictureSequenceView *seqView2 = new DPictureSequenceView(this); seqView2->setPictureSequence(seq); seqView2->setFixedSize(50, 50); seqView2->setSpeed(33); DPictureSequenceView *seqView3 = new DPictureSequenceView(this); seqView3->setPictureSequence(seq); seqView3->setFixedSize(50, 50); seqView3->setSpeed(66); DPictureSequenceView *seqView4 = new DPictureSequenceView(this); seqView4->setPictureSequence(seq2); seqView4->setFixedSize(50, 50); seqView4->setSpeed(20); DPictureSequenceView *seqView5 = new DPictureSequenceView(this); seqView5->setPictureSequence(seq2); seqView5->setFixedSize(50, 50); seqView5->setSpeed(33); DPictureSequenceView *seqView6 = new DPictureSequenceView(this); seqView6->setPictureSequence(seq2); seqView6->setFixedSize(50, 50); seqView6->setSpeed(66); auto seqViewLayout = new QHBoxLayout; seqViewLayout->addWidget(seqView); seqViewLayout->addWidget(seqView2); seqViewLayout->addWidget(seqView3); seqViewLayout->addWidget(seqView4); seqViewLayout->addWidget(seqView5); seqViewLayout->addWidget(seqView6); seqViewLayout->addStretch(); DPictureSequenceView *seqViewOnce = new DPictureSequenceView(this); seqViewOnce->setPictureSequence(seq); seqViewOnce->setFixedSize(50, 50); seqViewOnce->setSpeed(33); seqViewOnce->setSingleShot(true); DLinkButton *restart = new DLinkButton("Restart", this); auto seqOnceViewLayout = new QHBoxLayout; seqOnceViewLayout->addWidget(seqViewOnce); seqOnceViewLayout->addWidget(restart); seqOnceViewLayout->addStretch(); layout->addLayout(spinnerLayout); layout->addLayout(loadingContainerLayout); layout->addLayout(seqViewLayout); layout->addLayout(seqOnceViewLayout); layout->addStretch(); seqView->play(); seqView2->play(); seqView3->play(); seqView4->play(); seqView5->play(); seqView6->play(); connect(restart, &DLinkButton::clicked, [seqViewOnce] { seqViewOnce->play(); }); setLayout(layout); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/indicatortab.h000066400000000000000000000017471325435343100260750ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef INDICATORTAB_H #define INDICATORTAB_H #include #include #include #include "dloadingindicator.h" DWIDGET_USE_NAMESPACE class IndicatorTab : public QLabel { Q_OBJECT public: explicit IndicatorTab(QWidget *parent = 0); }; #endif // INDICATORTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/inputtab.cpp000066400000000000000000000101451325435343100256030ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "inputtab.h" #include "dshortcutedit.h" #include "dfilechooseredit.h" #include "dipv4lineedit.h" #include "dspinbox.h" #include "dcrumbedit.h" #include #include #include #include InputTab::InputTab(QWidget *parent) : QLabel(parent) { setStyleSheet("InputTab{background-color: #252627;}"); setFocusPolicy(Qt::ClickFocus); DTK_WIDGET_NAMESPACE::DPasswordEdit *pwdEdit = new DTK_WIDGET_NAMESPACE::DPasswordEdit(this); pwdEdit->setText("password"); pwdEdit->move(20, 20); pwdEdit->setContextMenuPolicy(Qt::DefaultContextMenu); DTK_WIDGET_NAMESPACE::DPasswordEdit *pwdEdit2 = new DTK_WIDGET_NAMESPACE::DPasswordEdit(this); pwdEdit2->setText("password"); pwdEdit2->setEchoMode(DTK_WIDGET_NAMESPACE::DPasswordEdit::Normal); pwdEdit2->setAlert(true); pwdEdit2->move(20, 50); connect(pwdEdit2, &DTK_WIDGET_NAMESPACE::DPasswordEdit::focusChanged, [](bool focus) {qDebug() << "focus: " << focus;}); connect(pwdEdit2, &DTK_WIDGET_NAMESPACE::DPasswordEdit::textChanged, [](const QString &text) {qDebug() << "text: " << text;}); DTK_WIDGET_NAMESPACE::DSearchEdit *searchEdit = new DTK_WIDGET_NAMESPACE::DSearchEdit(this); //searchEdit->setSearchIcon(":/images/button.png"); //searchEdit->setFixedWidth(300); searchEdit->move(20, 120); searchEdit->setPlaceHolder("Tes"); Dtk::Widget::DThemeManager::instance()->setTheme(searchEdit, "dark"); DTK_WIDGET_NAMESPACE::DLineEdit *lineEdit = new DTK_WIDGET_NAMESPACE::DLineEdit(this); lineEdit->setText("Test Alert Message"); lineEdit->move(20, 180); // lineEdit->setAlert(true); // lineEdit->setFixedSize(200, 30); connect(lineEdit, &DTK_WIDGET_NAMESPACE::DLineEdit::focusChanged, [](bool focus) {qDebug() << "focus: " << focus;}); QTimer::singleShot(2000, nullptr, [=] {lineEdit->showAlertMessage("Test Alert Message !!");}); DTK_WIDGET_NAMESPACE::DFileChooserEdit *fileChooser = new DTK_WIDGET_NAMESPACE::DFileChooserEdit(this); fileChooser->move(150, 180); fileChooser->setDialogDisplayPosition(DTK_WIDGET_NAMESPACE::DFileChooserEdit::CurrentMonitorCenter); DTK_WIDGET_NAMESPACE::DLineEdit *lineEditAlert = new DTK_WIDGET_NAMESPACE::DLineEdit(this); lineEditAlert->setText("AlertLineEdit"); lineEditAlert->setAlert(true); lineEditAlert->setFixedSize(200, 30); lineEditAlert->move(20, 230); lineEditAlert->setValidator(new QRegExpValidator(QRegExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){0,3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)?"))); DTK_WIDGET_NAMESPACE::DShortcutEdit *shortcutEdit = new DTK_WIDGET_NAMESPACE::DShortcutEdit(this); shortcutEdit->move(20, 300); DTK_WIDGET_NAMESPACE::DIpv4LineEdit *ipv4 = new DTK_WIDGET_NAMESPACE::DIpv4LineEdit(this); ipv4->move(300, 20); connect(ipv4, &DTK_WIDGET_NAMESPACE::DIpv4LineEdit::textChanged, this, [this, ipv4](const QString &text) { qDebug() << "text changed:" <text(); }); ipv4->setText("192.168.31.55"); DTK_WIDGET_NAMESPACE::DSpinBox *spinbox = new DTK_WIDGET_NAMESPACE::DSpinBox(this); spinbox->resize(100, 22); spinbox->move(300, 50); DTK_WIDGET_NAMESPACE::DCrumbEdit* crumbEdit = new DTK_WIDGET_NAMESPACE::DCrumbEdit(this); crumbEdit->resize(100, 50); // crumbEdit->setDualClickCreateCrumb(true); // crumbEdit->setCrumbReadOnly(true); crumbEdit->move(300, 100); // searchEdit->setFocus(); lineEditAlert->setFocus(); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/inputtab.h000066400000000000000000000016731325435343100252560ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef INPUTTAB_H #define INPUTTAB_H #include #include "dpasswordedit.h" #include "dsearchedit.h" #include "dlineedit.h" class InputTab : public QLabel { Q_OBJECT public: explicit InputTab(QWidget *parent = 0); }; #endif // INPUTTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/linetab.cpp000066400000000000000000000117571325435343100254050ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "linetab.h" LineTab::LineTab(QWidget *parent) : QLabel(parent) { // setStyleSheet("LineTab{background-color: #252627;}"); //////////////////////////////////////////////////////////////--DSeparator DSeparatorHorizontal *dsHorizontal = new DSeparatorHorizontal(this); dsHorizontal->setFixedSize(200,2); dsHorizontal->move(1,5); DSeparatorVertical *dsVertical = new DSeparatorVertical(this); dsVertical->setFixedSize(2,200); dsVertical->move(10,5); //////////////////////////////////////////////////////////////--DHeaderLine DHeaderLine *headerLine = new DHeaderLine(this); headerLine->setFixedSize(400, 30); headerLine->move(20,30); headerLine->setTitle("Control Library"); //////////////////////////////////////////////////////////////--DBaseLine DBaseLine * baseLine = new DBaseLine(this); baseLine->setLeftContent(new QLabel("DBaseLine")); QPushButton *bbb = new QPushButton("Test button",this); bbb->setStyleSheet("background-color: red"); baseLine->setRightContent(bbb); //////////////////////////////////////////////////////////////--DBaseExpand DBaseExpand *baseExpand = new DBaseExpand(this); baseExpand->setExpand(true); baseExpand->setFixedWidth(300); baseExpand->setHeader(baseLine); connect(bbb, &QPushButton::clicked, [=]{ baseExpand->setExpand(!baseExpand->expand()); }); DSeparatorHorizontal *dsHorizontal2 = new DSeparatorHorizontal(this); dsHorizontal2->setFixedWidth(baseExpand->width()); QLabel *expandLabel = new QLabel("Expand content"); expandLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); expandLabel->setFixedSize(200,50); baseExpand->setContent(expandLabel); baseExpand->move(20,70); dsHorizontal2->move(baseExpand->x(),baseExpand->y() - 2); /////////////////////////////////////////////////////////////--Right content QLabel *rightWidget = new QLabel(this); rightWidget->setFixedSize(300, 500); rightWidget->move(400, 0); QVBoxLayout *rightLayout = new QVBoxLayout(); rightLayout->setSpacing(0); rightLayout->setMargin(0); rightWidget->setLayout(rightLayout); /////////////////////////////////////////////////////////////--DArrowLineExpand DArrowLineExpand *arrowLineExpand = new DArrowLineExpand(); arrowLineExpand->setFixedWidth(300); arrowLineExpand->setTitle("Arrow Line Expand"); QLabel *expandLabel2 = new QLabel("Arrow Expand content"); expandLabel2->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); expandLabel2->setFixedSize(200,200); arrowLineExpand->setContent(expandLabel2); connect(arrowLineExpand, &DArrowLineExpand::expandChange, [=]{ expandLabel2->setFixedSize(expandLabel2->width(), expandLabel2->height() / 3 * 2); }); /////////////////////////////////////////////////////////////--DArrowLineExpand2 DArrowLineExpand *arrowLineExpand2 = new DArrowLineExpand(); arrowLineExpand2->setHeaderHeight(50); arrowLineExpand2->setFixedWidth(300); arrowLineExpand2->setTitle("Arrow Line Expand"); QLabel *expandLabel4 = new QLabel("Arrow Expand content"); expandLabel4->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); expandLabel4->setFixedSize(200,200); arrowLineExpand2->setContent(expandLabel4); /////////////////////////////////////////////////////////////--DSwitchLineExpand DSwitchLineExpand *switchLineExpand = new DSwitchLineExpand(); switchLineExpand->setFixedWidth(300); switchLineExpand->setTitle("Switch Line Expand"); QLabel *expandLabel3 = new QLabel("Switch Expand content"); expandLabel3->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); expandLabel3->setFixedSize(200,50); switchLineExpand->setContent(expandLabel3); DExpandGroup *group = new DExpandGroup(this); group->addExpand(arrowLineExpand); group->addExpand(arrowLineExpand2); rightLayout->addWidget(arrowLineExpand2); rightLayout->addWidget(arrowLineExpand); rightLayout->addWidget(switchLineExpand); rightLayout->addStretch(1); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/linetab.h000066400000000000000000000022151325435343100250370ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef LINETAB_H #define LINETAB_H #include #include #include #include "dheaderline.h" #include "dbaseline.h" #include "dseparatorhorizontal.h" #include "dseparatorvertical.h" #include "dbaseexpand.h" #include "darrowlineexpand.h" #include "dswitchlineexpand.h" #include "dexpandgroup.h" DWIDGET_USE_NAMESPACE class LineTab : public QLabel { Q_OBJECT public: explicit LineTab(QWidget *parent = 0); }; #endif // LINETAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/main.cpp000066400000000000000000000026011325435343100246770ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "mainwindow.h" #include "dlabel.h" #include "dapplication.h" #include "dplatformwindowhandle.h" #include #include #include "util/dwidgetutil.h" DWIDGET_USE_NAMESPACE int main(int argc, char *argv[]) { #if defined(DTK_STATIC_LIB) DWIDGET_INIT_RESOURCE(); #endif DApplication::loadDXcbPlugin(); DApplication a(argc, argv); a.setAttribute(Qt::AA_EnableHighDpiScaling, true); a.setTheme("light"); Dtk::Core::DLogManager::registerConsoleAppender(); if (!a.setSingleInstance("deepin-tool-kit-examples")) { qDebug() << "another instance is running!!"; } MainWindow w; w.show(); Dtk::Widget::moveToCenter(&w); return a.exec(); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/mainwindow.cpp000066400000000000000000000213031325435343100261270ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include "qsettingbackend.h" #include "dsettingsdialog.h" #include "dsettingsoption.h" #include "dsettings.h" #include "dslider.h" #include "dthememanager.h" #include "dtkwidget_global.h" #include "dswitchbutton.h" #include "segmentedcontrol.h" #include "dplatformwindowhandle.h" #include "dtitlebar.h" #include #include "mainwindow.h" #include "buttonlisttab.h" #include "cameraform.h" #include "graphicseffecttab.h" #include "simplelistviewtab.h" #include "dtoast.h" DCORE_USE_NAMESPACE DWIDGET_USE_NAMESPACE MainWindow::MainWindow(QWidget *parent) : DMainWindow(parent) { auto flags = windowFlags() & ~Qt::WindowMaximizeButtonHint; flags = flags & ~Qt::WindowMinimizeButtonHint; setWindowFlags(flags); DThemeManager *themeManager = DThemeManager::instance(); initTabWidget(); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setMargin(5); mainLayout->addWidget(m_mainTab); QHBoxLayout *styleLayout = new QHBoxLayout(); QPushButton *darkButton = new QPushButton("Dark", this); QPushButton *lightBUtton = new QPushButton("Light", this); QPushButton *enableButtons = new QPushButton("Enable Titlebar ", this); QPushButton *disableButtons = new QPushButton("Disable Titlebar", this); QPushButton *toggleMinMaxButtons = new QPushButton("Toggle MinMax", this); QPushButton *fullscreenButtons = new QPushButton("Fullscreen", this); themeManager->setTheme(lightBUtton, "light"); connect(darkButton, &QPushButton::clicked, [ = ] { themeManager->setTheme("dark"); }); connect(lightBUtton, &QPushButton::clicked, [ = ] { themeManager->setTheme("light"); }); connect(enableButtons, &QPushButton::clicked, [ = ] { titlebar()->setDisableFlags(Qt::Widget); }); connect(disableButtons, &QPushButton::clicked, [ = ] { titlebar()->setDisableFlags(Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowSystemMenuHint); }); connect(fullscreenButtons, &QPushButton::clicked, [ = ] { if (!isFullScreen()) { showFullScreen(); } else { showNormal(); } }); connect(toggleMinMaxButtons, &QPushButton::clicked, [ = ] { auto flags = windowFlags(); if (flags.testFlag(Qt::WindowMinimizeButtonHint)) { flags &= ~Qt::WindowMaximizeButtonHint; flags &= ~Qt::WindowMinimizeButtonHint; } else { flags |= Qt::WindowMaximizeButtonHint; flags |= Qt::WindowMinimizeButtonHint; } setWindowFlags(flags); show(); }); styleLayout->addWidget(darkButton); styleLayout->addWidget(lightBUtton); styleLayout->addWidget(enableButtons); styleLayout->addWidget(disableButtons); styleLayout->addWidget(toggleMinMaxButtons); styleLayout->addWidget(fullscreenButtons); styleLayout->addStretch(); mainLayout->addLayout(styleLayout); QWidget *centralWidget = new QWidget(this); centralWidget->setLayout(mainLayout); setCentralWidget(centralWidget); DTitlebar *titlebar = this->titlebar(); if (titlebar) { titlebar->setMenu(new QMenu(titlebar)); titlebar->setSeparatorVisible(true); titlebar->menu()->addAction("dfm-settings"); titlebar->menu()->addAction("dt-settings"); titlebar->menu()->addAction("testmenu1"); titlebar->menu()->addAction("testmenu2"); QMenu *menu = titlebar->menu()->addMenu("menu1"); menu->addAction("menu1->action1"); menu->addAction("menu1->action2"); connect(titlebar->menu(), &QMenu::triggered, this, &MainWindow::menuItemInvoked); titlebar->setDisableFlags(Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowSystemMenuHint); titlebar->setAutoHideOnFullscreen(true); } auto toast = new DToast(this); toast->setText("Successfully close window"); toast->setIcon(":/images/light/images/window/close_press.svg"); QTimer::singleShot(1000, [ = ]() { toast->pop(); toast->move((width() - toast->width()) / 2, (height() - toast->height()) / 2); }); QTimer::singleShot(4000, [ = ]() { toast->pop(); }); } void MainWindow::menuItemInvoked(QAction *action) { if (action->text() == "dfm-settings") { QTemporaryFile tmpFile; tmpFile.open(); auto backend = new Dtk::Core::QSettingBackend(tmpFile.fileName()); auto settings = Dtk::Core::DSettings::fromJsonFile(":/resources/data/dfm-settings.json"); settings->setBackend(backend); DSettingsDialog dsd(this); dsd.updateSettings(settings); dsd.exec(); return; } if (action->text() == "dt-settings") { QTemporaryFile tmpFile; tmpFile.open(); auto backend = new Dtk::Core::QSettingBackend(tmpFile.fileName()); auto settings = Dtk::Core::DSettings::fromJsonFile(":/resources/data/dt-settings.json"); settings->setBackend(backend); QFontDatabase fontDatabase; auto fontFamliy = settings->option("base.font.family"); QMap fontDatas; QStringList values = fontDatabase.families(); QStringList keys; for (auto &v : values) { keys << v.toLower().trimmed(); } fontDatas.insert("keys", keys); fontDatas.insert("values", values); fontFamliy->setData("items", fontDatas); // or you can set default value by json if (fontFamliy->value().toString().isEmpty()) { fontFamliy->setValue("droid serif"); } connect(fontFamliy, &DSettingsOption::valueChanged, this, [](QVariant value) { qDebug() << "fontFamliy change" << value; }); QStringList codings; for (auto coding : QTextCodec::availableCodecs()) { codings << coding; } auto encoding = settings->option("advance.encoding.encoding"); encoding->setData("items", codings); encoding->setValue(0); DSettingsDialog dsd(this); dsd.updateSettings(settings); dsd.exec(); return; } QMessageBox::warning(this, "menu clieck", action->text() + ", was cliecked"); qDebug() << "click" << action << action->isChecked(); } void MainWindow::initTabWidget() { m_mainTab = new QTabWidget(this); ComboBoxTab *comboBoxTab = new ComboBoxTab(this); LineTab *lineTab = new LineTab(this); BarTab *barTab = new BarTab(this); ButtonTab *buttonTab = new ButtonTab(this); InputTab *inputTab = new InputTab(this); SliderTab *sliderTab = new SliderTab(this); IndicatorTab *indicatorTab = new IndicatorTab(this); ButtonListTab *buttonListGroupTab = new ButtonListTab(this); Segmentedcontrol *segmentedControl = new Segmentedcontrol(this); WidgetsTab *widgetsTab = new WidgetsTab(this); CameraForm *cameraform = new CameraForm(this); GraphicsEffectTab *effectTab = new GraphicsEffectTab(this); SimpleListViewTab *simplelistviewTab = new SimpleListViewTab(this); m_mainTab->addTab(widgetsTab, "Widgets"); m_mainTab->addTab(effectTab, "GraphicsEffect"); m_mainTab->addTab(comboBoxTab, "ComboBox"); m_mainTab->addTab(indicatorTab, "Indicator"); m_mainTab->addTab(lineTab, "Line"); m_mainTab->addTab(barTab, "Bar"); m_mainTab->addTab(buttonTab, "Button"); m_mainTab->addTab(inputTab, "Input"); m_mainTab->addTab(sliderTab, "Slider"); m_mainTab->addTab(buttonListGroupTab, "ButtonList"); m_mainTab->addTab(segmentedControl, "Segmented Control"); m_mainTab->addTab(cameraform, "Camera View"); m_mainTab->addTab(simplelistviewTab, "SimpleListView"); m_mainTab->setCurrentIndex(0); } MainWindow::~MainWindow() { } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/mainwindow.h000066400000000000000000000025631325435343100256030ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include #include #include #include #include #include "widgets/dmainwindow.h" #include "bartab.h" #include "buttontab.h" #include "inputtab.h" #include "linetab.h" #include "slidertab.h" #include "indicatortab.h" #include "widgetstab.h" #include "comboboxtab.h" class QAction; DWIDGET_USE_NAMESPACE class MainWindow : public DMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); ~MainWindow(); protected Q_SLOTS: void menuItemInvoked(QAction *action); private: void initTabWidget(); private: QTabWidget *m_mainTab = NULL; }; #endif // MAINWINDOW_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/multilistitem.cpp000066400000000000000000000066371325435343100266750ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "multilistitem.h" #include DWIDGET_USE_NAMESPACE MultiListItem::MultiListItem(QString artistName, QString songName, QString songLength) { artist = artistName; song = songName; length = songLength; } bool MultiListItem::sameAs(DSimpleListItem *item) { return artist == (static_cast(item))->artist && song == (static_cast(item))->song && length == (static_cast(item))->length; } void MultiListItem::drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover) { QPainterPath path; path.addRect(QRectF(rect)); painter->setOpacity(1); if (isSelect) { painter->fillPath(path, QColor("#2CA7F8")); } else if (index % 2 == 1) { painter->fillPath(path, QColor("#D8D8D8")); } } void MultiListItem::drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover) { int padding = 10; painter->setOpacity(1); if (isSelect) { painter->setPen(QPen(QColor("#FFFFFF"))); } else { painter->setPen(QPen(QColor("#000000"))); } if (column == 0) { painter->drawText(QRect(rect.x() + padding, rect.y(), rect.width() - padding * 2, rect.height()), Qt::AlignLeft | Qt::AlignVCenter, artist); } else if (column == 1) { painter->drawText(QRect(rect.x() + padding, rect.y(), rect.width() - padding * 2, rect.height()), Qt::AlignLeft | Qt::AlignVCenter, song); } else if (column == 2) { painter->drawText(QRect(rect.x() + padding, rect.y(), rect.width() - padding * 2, rect.height()), Qt::AlignRight | Qt::AlignVCenter, length); } } bool MultiListItem::sortByArtist(const DSimpleListItem *item1, const DSimpleListItem *item2, bool descendingSort) { // Init. QString artist1 = (static_cast(item1))->artist; QString artist2 = (static_cast(item2))->artist; bool sortOrder = artist1 > artist2; return descendingSort ? sortOrder : !sortOrder; } bool MultiListItem::sortBySong(const DSimpleListItem *item1, const DSimpleListItem *item2, bool descendingSort) { // Init. QString song1 = (static_cast(item1))->song; QString song2 = (static_cast(item2))->song; bool sortOrder = song1 > song2; return descendingSort ? sortOrder : !sortOrder; } bool MultiListItem::sortByLength(const DSimpleListItem *item1, const DSimpleListItem *item2, bool descendingSort) { // Init. QString length1 = (static_cast(item1))->length; QString length2 = (static_cast(item2))->length; bool sortOrder = length1 > length2; return descendingSort ? sortOrder : !sortOrder; } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/multilistitem.h000066400000000000000000000031071325435343100263270ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef MULTILISTITEM_H #define MULTILISTITEM_H #include DWIDGET_USE_NAMESPACE class MultiListItem : public DSimpleListItem { Q_OBJECT public: MultiListItem(QString artistName, QString songName, QString songLength); bool sameAs(DSimpleListItem *item); void drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover); void drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover); static bool sortByArtist(const DSimpleListItem *item1, const DSimpleListItem *item2, bool descendingSort); static bool sortBySong(const DSimpleListItem *item1, const DSimpleListItem *item2, bool descendingSort); static bool sortByLength(const DSimpleListItem *item1, const DSimpleListItem *item2, bool descendingSort); QString artist; QString song; QString length; }; #endif dtkwidget-2.0.7.2/examples/dwidget-examples/collections/multilistview.cpp000066400000000000000000000045671325435343100267110ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "multilistview.h" #include "multilistitem.h" #include #include DWIDGET_USE_NAMESPACE MultiListView::MultiListView(DSimpleListView *parent) : DSimpleListView(parent) { QList items; MultiListItem *item1 = new MultiListItem("Bob Dylan", "Like A Rolling Stone", "5:56"); MultiListItem *item2 = new MultiListItem("Neil Young", "Old Man", "4:08"); MultiListItem *item3 = new MultiListItem("Eric Clapton", "Tears In Heaven", "4:34"); MultiListItem *item4 = new MultiListItem("John Lennon", "Imagine", "3:56"); items << item1; items << item2; items << item3; items << item4; QList titles; titles << "Artist" << "Song" << "Length"; QList widths; widths << 100 << -1 << 20; setColumnTitleInfo(titles, widths, 36); addItems(items); QList *alorithms = new QList(); alorithms->append(&MultiListItem::sortByArtist); alorithms->append(&MultiListItem::sortBySong); alorithms->append(&MultiListItem::sortByLength); setColumnSortingAlgorithms(alorithms, 0, true); connect(this, &MultiListView::rightClickItems, this, &MultiListView::popupMenu, Qt::QueuedConnection); } void MultiListView::popupMenu(QPoint pos, QList items) { QMenu *menu = new QMenu(); MultiListItem *item = static_cast(items[0]); QAction *artistAction = new QAction(item->artist, this); QAction *songAction = new QAction(item->song, this); QAction *lengthAction = new QAction(item->length, this); menu->addAction(artistAction); menu->addAction(songAction); menu->addAction(lengthAction); menu->exec(pos); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/multilistview.h000066400000000000000000000017531325435343100263500ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef MULTILISTVIEW_H #define MULTILISTVIEW_H #include DWIDGET_USE_NAMESPACE class MultiListView : public DSimpleListView { Q_OBJECT public: MultiListView(DSimpleListView *parent=0); public Q_SLOTS: void popupMenu(QPoint pos, QList items); }; #endif dtkwidget-2.0.7.2/examples/dwidget-examples/collections/resources.qrc000066400000000000000000000002441325435343100257710ustar00rootroot00000000000000 resources/data/dfm-settings.json resources/data/dt-settings.json dtkwidget-2.0.7.2/examples/dwidget-examples/collections/resources/000077500000000000000000000000001325435343100252625ustar00rootroot00000000000000dtkwidget-2.0.7.2/examples/dwidget-examples/collections/resources/data/000077500000000000000000000000001325435343100261735ustar00rootroot00000000000000dtkwidget-2.0.7.2/examples/dwidget-examples/collections/resources/data/dfm-settings.json000066400000000000000000000040061325435343100314720ustar00rootroot00000000000000{ "gsettings": { "id": "com.deepin.filemanager", "path": "/com/deepin/filemanager/" }, "groups": [ { "key": "base", "name": "Basic settings", "groups": [ { "key": "open_action", "name": "Open Action", "options": [ { "key": "alway_open_on_new", "type": "checkbox", "text": "Always Open On New Windows", "default": true }, { "key": "open_file_action", "name": "Open File:", "type": "combobox", "default": "" } ] }, { "key": "new_tab_windows", "name": "New Tab & Window", "options": [ { "key": "new_window_path", "name": "New Window Open:", "type": "combobox", "default": "" }, { "key": "new_tab_path", "name": "New Tab Open:", "type": "combobox", "default": "" } ] }, { "key": "default_view", "name": "Default View", "options": [ { "key": "icon_size", "name": "Icon Size:", "type": "combobox", "default": "" } ] } ] } ] } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/resources/data/dt-settings.json000066400000000000000000000171621325435343100313420ustar00rootroot00000000000000{ "groups": [ { "key": "base", "name": "Basic settings", "groups": [ { "key": "theme", "name": "Theme", "options": [ { "key": "theme", "type": "checkpicture", "default": 0 }, { "key": "opticy", "name": "Opticy", "type": "slider", "max": 100, "min": 0, "default": 90 } ] }, { "key": "font", "name": "Font Style", "options": [ { "key": "family", "name": "Font", "type": "combobox", "default": "" }, { "key": "size", "name": "Font Size", "type": "spinbutton", "default": 12 }, { "key": "style", "name": "Font Style", "type": "buttongroup", "items": ["B","/"], "default": 0 } ] } ] }, { "key": "shortcuts", "name": "Shortcuts", "groups": [ { "key": "ternimal", "name": "Ternimal", "hide": true, "options": [ { "key": "copy", "name": "Copy", "type": "shortcut", "default": "Ctrl+Alt+C" }, { "key": "paste", "name": "Paste", "type": "shortcut", "default": "Ctrl+Alt+V" }, { "key": "scroll_up", "name": "Scroll Up", "type": "shortcut", "default": "Alt+." }, { "key": "scroll_down", "name": "Scroll down", "type": "shortcut", "default": "Alt+," } ] }, { "key": "workspace", "name": "Workspace", "options": [ { "key": "new_window", "name": "New Window", "type": "shortcut", "default": "Ctrl+Shitf+<" }, { "key": "next_tab", "name": "Next Tab", "type": "shortcut", "default": "Ctrl+N" }, { "key": "prev_up", "name": "Previous Tab", "type": "shortcut", "default": "Ctrl+Shitf+>" }, { "key": "close_tab", "name": "Close Tab", "type": "shortcut", "default": "Ctrl+W" } ] } ] }, { "key": "advance", "name": "Advance", "groups": [ { "key": "cursor", "name": "Cursor", "options": [ { "key": "shrap", "name": "Cursor Shrap", "type": "buttongroup", "items": ["█","_","|"], "default": 0 }, { "key": "blink", "type": "checkbox", "text": "Cursor blink", "default": true }, { "key": "radiogroup", "name": " ", "type": "radiogroup", "items": ["Minimize to tray","Exit Deepin Music"], "default": 0 } ] }, { "key": "encoding", "name": "Default encoding", "options": [ { "key": "encoding", "name": "Encoding", "type": "combobox", "default": "utf-8" } ] }, { "key": "coustom", "name": "Coustom", "options": [ { "key": "coustom_command", "name": "Coustom Command", "type": "lineedit", "default": "" }, { "key": "coustom_directory", "name": "Coustom Directory", "type": "lineedit", "default": "" } ] }, { "key": "scroll", "name": "Scroll", "options": [ { "key": "scroll_bottom", "text": "Scroll Bottom", "type": "checkbox", "default": "" }, { "key": "scroll_line_count", "name": "Scroll line count", "type": "spinbutton", "default": 10 } ] }, { "key": "compatibility", "name": "Compatibility", "options": [ { "key": "breakspce_action", "name": "Breakspce Action", "type": "combobox", "default": "" }, { "key": "delete_action", "name": "Delete Action", "type": "combobox", "default": "" } ] } ] } ] } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/segmentedcontrol.cpp000066400000000000000000000030161325435343100273300ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "segmentedcontrol.h" #include Segmentedcontrol::Segmentedcontrol(QWidget *parent) : QFrame(parent), segmentedControl(new DSegmentedControl(this)) { setStyleSheet("Segmentedcontrol{background: #1e1e1e;}"); segmentedControl->addSegmented("page1"); segmentedControl->addSegmented("page2"); segmentedControl->addSegmented("page3"); segmentedControl->move(100, 50); QLabel *label = new QLabel(this); QPalette pa = label->palette(); pa.setColor(QPalette::Foreground, Qt::white); label->setPalette(pa); label->move(100, 150); label->setText(QString("current paga %1").arg(segmentedControl->currentIndex()+1)); connect(segmentedControl, &DSegmentedControl::currentChanged, [=](){ label->setText(QString("current paga %1").arg(segmentedControl->currentIndex()+1)); }); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/segmentedcontrol.h000066400000000000000000000020351325435343100267750ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef SEGMENTEDCONTROL_H #define SEGMENTEDCONTROL_H #include #include "dsegmentedcontrol.h" #include "dtkwidget_global.h" DWIDGET_USE_NAMESPACE class Segmentedcontrol : public QFrame { Q_OBJECT public: explicit Segmentedcontrol(QWidget *parent = 0); private: DSegmentedControl *segmentedControl; }; #endif // SEGMENTEDCONTROL_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/simplelistviewtab.cpp000066400000000000000000000022221325435343100275210ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "simplelistviewtab.h" #include "singlelistview.h" #include "multilistview.h" SimpleListViewTab::SimpleListViewTab(QWidget *parent) : QWidget(parent) { QHBoxLayout *layout = new QHBoxLayout(this); SingleListView *singleListView = new SingleListView(); MultiListView *multiListView = new MultiListView(); layout->addWidget(singleListView); layout->addWidget(multiListView); } SimpleListViewTab::~SimpleListViewTab() { } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/simplelistviewtab.h000066400000000000000000000016241325435343100271730ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef SIMPLEVIEWTAB_H #define SIMPLEVIEWTAB_H #include class SimpleListViewTab : public QWidget { Q_OBJECT public: SimpleListViewTab(QWidget *parent=0); ~SimpleListViewTab(); }; #endif dtkwidget-2.0.7.2/examples/dwidget-examples/collections/singlelistitem.cpp000066400000000000000000000033751325435343100270200ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "singlelistitem.h" #include DWIDGET_USE_NAMESPACE SingleListItem::SingleListItem(QString itemName) { name = itemName; } bool SingleListItem::sameAs(DSimpleListItem *item) { return name == (static_cast(item))->name; } void SingleListItem::drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover) { QPainterPath path; path.addRect(QRectF(rect)); painter->setOpacity(1); if (isSelect) { painter->fillPath(path, QColor("#2CA7F8")); } else if (index % 2 == 1) { painter->fillPath(path, QColor("#D8D8D8")); } } void SingleListItem::drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover) { painter->setOpacity(1); if (isSelect) { painter->setPen(QPen(QColor("#FFFFFF"))); } else { painter->setPen(QPen(QColor("#000000"))); } int padding = 10; painter->drawText(QRect(rect.x() + padding, rect.y(), rect.width() - padding * 2, rect.height()), Qt::AlignLeft | Qt::AlignVCenter, name); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/singlelistitem.h000066400000000000000000000022531325435343100264570ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef SINGLELISTITEM_H #define SINGLELISTITEM_H #include DWIDGET_USE_NAMESPACE class SingleListItem : public DSimpleListItem { Q_OBJECT public: SingleListItem(QString itemName); bool sameAs(DSimpleListItem *item); void drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover); void drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover); QString name; }; #endif dtkwidget-2.0.7.2/examples/dwidget-examples/collections/singlelistview.cpp000066400000000000000000000022141325435343100270230ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "singlelistview.h" #include "singlelistitem.h" DWIDGET_USE_NAMESPACE SingleListView::SingleListView(DSimpleListView *parent) : DSimpleListView(parent) { QStringList rockStars; rockStars << "Bob Dylan" << "Neil Young" << "Eric Clapton" << "John Lennon"; QList items; for (auto rockStarName : rockStars){ SingleListItem *item = new SingleListItem(rockStarName); items << item; } addItems(items); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/singlelistview.h000066400000000000000000000016441325435343100264760ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef SINGLELISTVIEW_H #define SINGLELISTVIEW_H #include DWIDGET_USE_NAMESPACE class SingleListView : public DSimpleListView { Q_OBJECT public: SingleListView(DSimpleListView *parent=0); }; #endif dtkwidget-2.0.7.2/examples/dwidget-examples/collections/slidertab.cpp000066400000000000000000000023531325435343100257300ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dslider.h" #include "slidertab.h" DWIDGET_USE_NAMESPACE SliderTab::SliderTab(QWidget *parent) : QLabel(parent) { setStyleSheet("SliderTab{background-color: #1A1B1B}"); DSlider * slider = new DSlider(Qt::Horizontal, this); slider->setFixedWidth(300); slider->setFixedHeight(40); slider->move(20, 50); DSlider *sharpSlider = new DSlider(Qt::Horizontal, this); sharpSlider->setHandleType(DSlider::SharpHandler); sharpSlider->setFixedWidth(300); sharpSlider->setFixedHeight(40); sharpSlider->move(20, 100); } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/slidertab.h000066400000000000000000000016061325435343100253750ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef SLIDERTAB_H #define SLIDERTAB_H #include #include class SliderTab : public QLabel { Q_OBJECT public: explicit SliderTab(QWidget *parent = 0); }; #endif // SLIDERTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/collections/widgetstab.cpp000066400000000000000000000060161325435343100261140ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "widgetstab.h" #include "darrowrectangle.h" #ifdef Q_OS_LINUX #include "dmpriscontrol.h" #include "dregionmonitor.h" using Dtk::Widget::DRegionMonitor; #endif #include WidgetsTab::WidgetsTab(QWidget *parent) : QLabel(parent) { setStyleSheet("WidgetsTab {background-color:#252627;} QCheckBox {color:#666;}"); #ifdef Q_OS_LINUX DRegionMonitor *rm = new DRegionMonitor(this); rm->registerRegion(QRegion(0, 0, 500, 500)); Q_ASSERT(rm->registered()); connect(rm, &DRegionMonitor::buttonPress, [=](const QPoint &p, const int flag) { qDebug() << "btn press:" << p << flag; }); connect(rm, &DRegionMonitor::buttonRelease, [=](const QPoint &p, const int flag) { qDebug() << "btn release:" << p << flag; }); #endif QCheckBox *lunarVisible = new QCheckBox(this); lunarVisible->setText("lunar visible"); lunarVisible->move(320, 50); lunarVisible->setChecked(true); QCheckBox *festivalHighlight = new QCheckBox(this); festivalHighlight->setText("lunar festival highlight"); festivalHighlight->setChecked(true); festivalHighlight->move(320, 80); QCheckBox *cellSelectable = new QCheckBox(this); cellSelectable->setText("cell selectable"); cellSelectable->setChecked(true); cellSelectable->move(320, 110); QCheckBox *controlPanelVisible = new QCheckBox(this); controlPanelVisible->setText("control panel visible"); controlPanelVisible->move(320, 140); controlPanelVisible->setChecked(true); QCheckBox *dateInfoVisible = new QCheckBox(this); dateInfoVisible->setText("date info visible"); dateInfoVisible->setChecked(false); dateInfoVisible->move(320, 170); ////////////////////ArrowRectangle////////////////// DArrowRectangle *rectangle = new DArrowRectangle(DArrowRectangle::ArrowLeft); // rectangle->setArrowY(15); rectangle->setArrowX(25); rectangle->setArrowWidth(30); rectangle->setArrowHeight(10); QPushButton *button = new QPushButton("DArrowRectangle Test"); button->setFixedSize(200, 30); rectangle->setContent(button); rectangle->show(200, 200); rectangle->setBackgroundColor(QColor(255, 255, 255, 0.5)); #ifdef Q_OS_LINUX // mpris DMPRISControl *control = new DMPRISControl(this); control->setFixedSize(300, 300); control->move(500, 0); control->setStyleSheet("background-color:red;"); #endif } dtkwidget-2.0.7.2/examples/dwidget-examples/collections/widgetstab.h000066400000000000000000000016511325435343100255610ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef WIDGETSTAB_H #define WIDGETSTAB_H #include #include "dtextbutton.h" DWIDGET_USE_NAMESPACE class WidgetsTab : public QLabel { Q_OBJECT public: explicit WidgetsTab(QWidget *parent = 0); }; #endif // WIDGETSTAB_H dtkwidget-2.0.7.2/examples/dwidget-examples/dwidget-examples.pro000066400000000000000000000000531325435343100247150ustar00rootroot00000000000000TEMPLATE = subdirs SUBDIRS += collections dtkwidget-2.0.7.2/examples/examples.pro000066400000000000000000000000601325435343100200230ustar00rootroot00000000000000TEMPLATE = subdirs SUBDIRS += dwidget-examples dtkwidget-2.0.7.2/src/000077500000000000000000000000001325435343100144405ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/config.pri000066400000000000000000000012651325435343100164250ustar00rootroot00000000000000isEmpty(VERSION) { PKG_CONFIG_EXE = $$first($$list($$pkgConfigExecutable())) isEmpty(LIB_INSTALL_DIR) { dtk_version_module = $$system($$PKG_CONFIG_EXE --variable=libdir dtkcore) dtk_version_module = $$dtk_version_module/libdtk/modules/version.pri exists($$dtk_version_module): include($$dtk_version_module) else: VERSION = $$system($$PKG_CONFIG_EXE --modversion dtkcore) } else { dtk_version_module = $$LIB_INSTALL_DIR/libdtk/modules/version.pri exists($$dtk_version_module): include($$dtk_version_module) else: VERSION = $$system($$PKG_CONFIG_EXE --modversion dtkcore) } isEmpty(VERSION): error(VERSION is empty) } dtkwidget-2.0.7.2/src/config.tests/000077500000000000000000000000001325435343100170465ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/config.tests/libdframeworkdbus/000077500000000000000000000000001325435343100225545ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/config.tests/libdframeworkdbus/libdframeworkdbus.pro000066400000000000000000000017011325435343100270030ustar00rootroot00000000000000#------------------------------------------------- # # Project created by QtCreator 2018-01-16T15:58:01 # #------------------------------------------------- CONFIG += qt QT += core dbus QT -= gui TARGET = libdframeworkdbus TEMPLATE = app CONFIG += c++11 link_pkgconfig PKGCONFIG += dframeworkdbus # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp dtkwidget-2.0.7.2/src/config.tests/libdframeworkdbus/main.cpp000066400000000000000000000001361325435343100242040ustar00rootroot00000000000000#include int main(int argc, char *argv[]) { return 0; } dtkwidget-2.0.7.2/src/dtkwidget_global.h000066400000000000000000000054271325435343100201270ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include #define DWIDGET_NAMESPACE Widget #define DTK_WIDGET_NAMESPACE DTK_NAMESPACE::Widget #define DWIDGET_BEGIN_NAMESPACE namespace DTK_NAMESPACE { namespace DWIDGET_NAMESPACE { #define DWIDGET_END_NAMESPACE }} #define DWIDGET_USE_NAMESPACE using namespace DTK_WIDGET_NAMESPACE; namespace Dtk { namespace Widget { #if defined(DTK_STATIC_LIB) #define DWIDGET_INIT_RESOURCE() \ do { \ Q_INIT_RESOURCE(icons); \ Q_INIT_RESOURCE(dui_theme_dark); \ Q_INIT_RESOURCE(dui_theme_light); } while (0) #endif } } #if defined(DTK_STATIC_LIB) # define LIBDTKWIDGETSHARED_EXPORT #else #if defined(LIBDTKWIDGET_LIBRARY) # define LIBDTKWIDGETSHARED_EXPORT Q_DECL_EXPORT #else # define LIBDTKWIDGETSHARED_EXPORT Q_DECL_IMPORT #endif #endif #define DTKWIDGET_DECL_DEPRECATED D_DECL_DEPRECATED #define D_THEME_INIT_WIDGET(className, ...) do{\ DThemeManager * manager = DThemeManager::instance(); \ {const QString &sheet = this->styleSheet() + manager->getQssForWidget(#className, this); \ if (!sheet.isEmpty()) this->setStyleSheet(sheet); \ } \ connect(manager, &DThemeManager::themeChanged, this, [this, manager] (QString) { \ const QString &sheet = manager->getQssForWidget(#className, this); \ if (!sheet.isEmpty()) this->setStyleSheet(sheet); \ });\ connect(manager, &DThemeManager::widgetThemeChanged, this, [this, manager] (QWidget *w, QString) { \ if (w == this) this->setStyleSheet(manager->getQssForWidget(#className, this)); \ }); \ QStringList list = QString(#__VA_ARGS__).replace(" ", "").split(",");\ const QMetaObject *self = metaObject();\ Q_FOREACH (const QString &str, list) {\ if(str.isEmpty())\ continue;\ connect(this, self->property(self->indexOfProperty(str.toLatin1().data())).notifySignal(),\ manager, manager->metaObject()->method(manager->metaObject()->indexOfMethod("updateQss()")));\ } \ } while (0); dtkwidget-2.0.7.2/src/lib.pri000066400000000000000000000013071325435343100157230ustar00rootroot00000000000000include($$PWD/config.pri) CONFIG += c++11 create_pc create_prl no_install_prl isEmpty(LIB_INSTALL_DIR) { target.path = $$PREFIX/lib } else { target.path = $$LIB_INSTALL_DIR } message("Build dtkwidget version: $${VERSION}") QMAKE_PKGCONFIG_LIBDIR = $$target.path QMAKE_PKGCONFIG_VERSION = $$VERSION QMAKE_PKGCONFIG_DESTDIR = pkgconfig isEmpty(INCLUDE_INSTALL_DIR) { DTK_INCLUDEPATH = $$PREFIX/include/libdtk-$${VER_MAJ}.$${VER_MIN}.$${VER_PAT} } else { DTK_INCLUDEPATH = $$INCLUDE_INSTALL_DIR/libdtk-$${VER_MAJ}.$${VER_MIN}.$${VER_PAT} } load(configure) qtCompileTest(libdframeworkdbus) { DEFINES += DBUS_VERSION_0_4_2 } INSTALLS += includes target win32* { CONFIG += staticlib } dtkwidget-2.0.7.2/src/platforms/000077500000000000000000000000001325435343100164475ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/platforms/mac/000077500000000000000000000000001325435343100172075ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/platforms/mac/osxwindow.h000066400000000000000000000013651325435343100214260ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ namespace OSX { void HideWindowTitlebar(long winid); } dtkwidget-2.0.7.2/src/platforms/mac/osxwindow.mm000066400000000000000000000025311325435343100216040ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "osxwindow.h" #include namespace OSX { void HideWindowTitlebar(long winId) { NSView *view = reinterpret_cast(winId); NSWindow* window = [view window]; [window setStyleMask: [window styleMask] | NSFullSizeContentViewWindowMask | NSWindowTitleHidden]; [window setTitlebarAppearsTransparent:YES]; [window setMovableByWindowBackground:YES]; [[window standardWindowButton:NSWindowCloseButton] setHidden:YES]; [[window standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES]; [[window standardWindowButton:NSWindowZoomButton] setHidden:YES]; window.titleVisibility = NSWindowTitleHidden; } } dtkwidget-2.0.7.2/src/platforms/platforms.pri000066400000000000000000000001351325435343100211710ustar00rootroot00000000000000 linux { include($$PWD/x11/x11.pri) } win32* { include($$PWD/windows/windows.pri) } dtkwidget-2.0.7.2/src/platforms/windows/000077500000000000000000000000001325435343100201415ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/platforms/windows/popupmenustyle.cpp000066400000000000000000000311721325435343100237620ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "popupmenustyle.h" #include #include #include #include #include #include namespace { const QString SUB_MENU_NORMAL_ICON = ":/images/resources/images/sub_menu_normal.png"; const QString SUB_MENU_HOVER_ICON = ":/images/resources/images/sub_menu_hover.png"; const qreal FRAME_BORDER_WIDTH = 0.5; const int FRAME_BORDER_RADIUS = 4; const int ITEM_HEIGHT = 21; const int ICON_PIXEL_SIZE = 16; const int ICON_LEFT_MARGIN = 4; const int TEXT_LEFT_MARGIN = 4; const int SEPARATOR_HEIGHT = 9; const int SEPARATOR_LEFT_MARGIN = 11; const int SEPARATOR_RIGHT_MARGIN = 10; const int TEXT_FONT_PIXEL_SIZE = 12; const int SHORTCUT_FONT_PIXEL_SIZE = 10; const QColor FRAME_BORDER_COLOR = QColor(255, 255, 255, 51); const QColor TEXT_COLOR = QColor("#ffffff"); const QColor SHORTCUT_COLOR = QColor(255, 255, 255, 153); const QColor SHORTCUT_HOVER_COLOR = QColor(255, 255, 255, 255); const QColor ITEM_BG_NORMAL_COLOR = QColor(0, 0, 0, 204); const QColor ITEM_BG_HOVER_COLOR = QColor(0, 188, 255, 255); const QColor SEPARATOR_COLOR = QColor(255, 255, 255, 51); } // namespace PopupMenuStyle::PopupMenuStyle() : QProxyStyle() { } int PopupMenuStyle::styleHint(QStyle::StyleHint hint, const QStyleOption* option, const QWidget* widget, QStyleHintReturn* returnData) const { switch (hint) { case QStyle::SH_Menu_Scrollable: return 1; case QStyle::SH_Menu_KeyboardSearch: return 0; default: return QProxyStyle::styleHint(hint, option, widget, returnData); } } int PopupMenuStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option, const QWidget* widget) const { switch (metric) { case QStyle::PM_MenuScrollerHeight: return 15; case QStyle::PM_MenuDesktopFrameWidth: return 0; case QStyle::PM_SubMenuOverlap: return -1; case QStyle::PM_MenuVMargin: return 8; default: return QProxyStyle::pixelMetric(metric, option, widget); } } void PopupMenuStyle::drawControl(QStyle::ControlElement control, const QStyleOption* option, QPainter* painter, const QWidget* widget) const { switch (control) { case QStyle::CE_MenuItem: drawMenuItem(option, painter); break; // case QStyle::CE_MenuScroller: // drawScroller(option, painter); // break; default: QProxyStyle::drawControl(control, option, painter, widget); } } void PopupMenuStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (element == QStyle::PE_PanelMenu) { painter->setRenderHint(QPainter::Antialiasing); QPainterPath path; // Skill // Make path's corner draw smooth // http://www.cnblogs.com/smileEvday/p/iOS_PixelVsPoint.html QRectF rect = option->rect; rect.setTopLeft(QPointF(0.5, 0.5)); rect.setBottomRight(QPointF(rect.width() - 1, rect.height() - 1)); path.addRoundedRect(rect, FRAME_BORDER_RADIUS, FRAME_BORDER_RADIUS); painter->fillPath(path, QBrush(ITEM_BG_NORMAL_COLOR)); // Do not draw outside border if it's sub-menu if (widget->parentWidget()) { // Skill // Draw outside border QPainterPathStroker stroker; stroker.setWidth(FRAME_BORDER_WIDTH); stroker.setJoinStyle(Qt::RoundJoin); QPainterPath borderPath = stroker.createStroke(path); QPen pen(FRAME_BORDER_COLOR, FRAME_BORDER_WIDTH); painter->setPen(pen); painter->drawPath(borderPath); } } else { QProxyStyle::drawPrimitive(element, option, painter, widget); } } QSize PopupMenuStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget) const { QSize originSize = QProxyStyle::sizeFromContents(type, option, contentsSize, widget); switch (type) { case QStyle::CT_MenuItem: return getItemSize(option, originSize); default: return originSize; } } void PopupMenuStyle::drawScroller(const QStyleOption *option, QPainter *painter) const { Q_UNUSED(option) Q_UNUSED(painter) // QRect rect = option->rect; // // Draw background // painter->drawPixmap(rect, QPixmap(kItemNormalBackground)); // // Draw arrow // QPixmap arrow_pixmap = getArrowPixmap(option->state); // QRect arrow_rect(rect.x() + (rect.width() - arrow_pixmap.width()) / 2, // rect.y() + (rect.height() - arrow_pixmap.height()) / 2, // arrow_pixmap.width(), // arrow_pixmap.height()); // painter->drawPixmap(arrow_rect, arrow_pixmap); } void PopupMenuStyle::drawMenuItem(const QStyleOption* option, QPainter* painter) const { if (const QStyleOptionMenuItem* menuItem = qstyleoption_cast(option)) { if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { drawSeparator(menuItem, painter); } else { // Draw background painter->fillRect(menuItem->rect, QBrush(getItemBGColor(menuItem->state))); drawMenuItemIcon(menuItem, painter); drawMenuItemText(menuItem, painter); drawMenuItemSubIcon(menuItem, painter); drawMenuItemCheckedIcon(menuItem, painter); } } } void PopupMenuStyle::drawSeparator(const QStyleOptionMenuItem *menuItem, QPainter *painter) const { // painter->fillRect(menuItem->rect, QBrush(ITEM_BG_NORMAL_COLOR)); const int x1 = menuItem->rect.x() + SEPARATOR_LEFT_MARGIN; const int x2 = menuItem->rect.x() + menuItem->rect.width() - SEPARATOR_RIGHT_MARGIN; const int y = menuItem->rect.y() + (SEPARATOR_HEIGHT - 1) / 2; // Note pixel calculate kill, make sure draw the line is 1px height QLineF line(x1, y + 0.5, x2, y + 0.5); QPen pen(SEPARATOR_COLOR, 1); painter->setPen(pen); painter->drawLine(line); } void PopupMenuStyle::drawMenuItemIcon(const QStyleOptionMenuItem* menuItem, QPainter* painter) const { QPixmap pixmap = getIconPixmap(menuItem->state, menuItem->icon, QSize(ICON_PIXEL_SIZE, ICON_PIXEL_SIZE)); if (pixmap.isNull()) { return; } int y = menuItem->rect.y() + (menuItem->rect.height() - pixmap.height()) / 2; painter->drawPixmap(ICON_LEFT_MARGIN, y, pixmap.width(), pixmap.height(), pixmap); } void PopupMenuStyle::drawMenuItemText(const QStyleOptionMenuItem* menuItem, QPainter* painter) const { int width = menuItem->rect.width(); int height = menuItem->rect.height(); int y = menuItem->rect.y(); // Draw shortcut QFont shortcutFont; shortcutFont.setPixelSize(SHORTCUT_FONT_PIXEL_SIZE); QFontMetrics shortcutFM(shortcutFont); const QString shortcutContent = menuItem->text.split(SHORTCUT_SPLIT_FLAG).last(); const int shortcutWidth = shortcutFM.width(shortcutContent.trimmed()); const int shortcutX = width - SEPARATOR_RIGHT_MARGIN - shortcutWidth; QPen shortcutPen((menuItem->state & QStyle::State_Selected) ? SHORTCUT_HOVER_COLOR : SHORTCUT_COLOR); painter->setPen(shortcutPen); painter->setFont(shortcutFont); painter->drawText(shortcutX, y, shortcutWidth, height, Qt::AlignRight | Qt::AlignVCenter, shortcutContent); // Draw title QFont titleFont; titleFont.setPixelSize(TEXT_FONT_PIXEL_SIZE); QFontMetrics titleFM(titleFont); const QString titleContent = menuItem->text.split(SHORTCUT_SPLIT_FLAG).first(); int leftSpacing = ICON_LEFT_MARGIN + ICON_PIXEL_SIZE + TEXT_LEFT_MARGIN; const int titleWidth = width - leftSpacing - shortcutWidth - SEPARATOR_LEFT_MARGIN; int titleX = leftSpacing; QPen titlePen(TEXT_COLOR); painter->setPen(titlePen); painter->setFont(titleFont); painter->drawText(titleX, y, titleWidth, height, Qt::AlignLeft | Qt::AlignVCenter, titleFM.elidedText(titleContent, Qt::ElideRight, titleWidth)); } void PopupMenuStyle::drawMenuItemSubIcon(const QStyleOptionMenuItem* menuItem, QPainter* painter) const { // Draw sub-menu icon if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) { QPixmap pixmap(getSubMenuPixmap(menuItem->state)); int height = menuItem->rect.height(); int x = menuItem->rect.width() - TEXT_LEFT_MARGIN - ICON_PIXEL_SIZE; int y = menuItem->rect.y() + (height - pixmap.height()) / 2; painter->drawPixmap(x, y, pixmap.width(), pixmap.height(), pixmap); } } void PopupMenuStyle::drawMenuItemCheckedIcon(const QStyleOptionMenuItem* menuItem, QPainter* painter) const { Q_UNUSED(menuItem) Q_UNUSED(painter) // if (menuItem->checked) { // QPixmap pixmap; // QPixmapCache::find(kCheckedIconCacheKey, &pixmap); // int height = menuItem->rect.height(); // int x = menuItem->rect.width() - TEXT_LEFT_MARGIN - ICON_PIXEL_SIZE; // int y = menuItem->rect.y() + (height - pixmap.height()) / 2; // painter->drawPixmap(x, y, pixmap.width(), pixmap.height(), pixmap); // } } QSize PopupMenuStyle::getItemSize(const QStyleOption* option, const QSize& size) const { const int m = SEPARATOR_LEFT_MARGIN + SEPARATOR_RIGHT_MARGIN; if (const QStyleOptionMenuItem* menuItem = qstyleoption_cast(option)) { switch (menuItem->menuItemType) { case QStyleOptionMenuItem::Separator: return QSize(size.width() / 2 + m, SEPARATOR_HEIGHT); case QStyleOptionMenuItem::Normal: case QStyleOptionMenuItem::SubMenu: return QSize(size.width() / 2 + m, ITEM_HEIGHT); default: return size; } } else { return size; } } QColor PopupMenuStyle::getItemBGColor(const QStyle::State state) const { // QStyle::State_MouseOver not working, don't know why if (state & QStyle::State_Selected) { return ITEM_BG_HOVER_COLOR; } else { return QColor(0, 0, 0, 0); } } QPixmap PopupMenuStyle::getSubMenuPixmap(const QStyle::State state) const { if (state & QStyle::State_Selected) { return SUB_MENU_HOVER_ICON; } else { return SUB_MENU_NORMAL_ICON; } } QPixmap PopupMenuStyle::getIconPixmap(const QStyle::State state, const QIcon& icon, const QSize& size) const { QIcon::Mode iconMode = QIcon::Normal; QIcon::State iconState = QIcon::Off; if (state & QStyle::State_Active) { iconMode = QIcon::Active; } else if (state & QStyle::State_Selected) { iconMode = QIcon::Selected; } else if (!(state & QStyle::State_Enabled)) { iconMode = QIcon::Disabled; } if (state & QStyle::State_On) { iconState = QIcon::On; } return icon.pixmap(size, iconMode, iconState); } dtkwidget-2.0.7.2/src/platforms/windows/popupmenustyle.h000066400000000000000000000057571325435343100234410ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef POPUPMENUSTYLEH #define POPUPMENUSTYLEH #include const QString SHORTCUT_SPLIT_FLAG = "@-_-@"; class QStyleOptionMenuItem; class PopupMenuStyle : public QProxyStyle { Q_OBJECT public: PopupMenuStyle(); int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const; int pixelMetric(PixelMetric metric, const QStyleOption* option = 0, const QWidget* widget = 0) const; void drawControl(ControlElement control, const QStyleOption* option, QPainter* painter, const QWidget* widget) const; void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = Q_NULLPTR) const; QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget = 0) const; private: void drawScroller(const QStyleOption* option, QPainter* painter) const; void drawMenuItem(const QStyleOption* option, QPainter* painter) const; void drawSeparator(const QStyleOptionMenuItem* menuItem, QPainter* painter) const; void drawMenuItemIcon(const QStyleOptionMenuItem* menuItem, QPainter* painter) const; void drawMenuItemText(const QStyleOptionMenuItem* menuItem, QPainter* painter) const; void drawMenuItemSubIcon(const QStyleOptionMenuItem* menuItem, QPainter* painter) const; void drawMenuItemCheckedIcon(const QStyleOptionMenuItem* menuItem, QPainter* painter) const; QSize getItemSize(const QStyleOption* option, const QSize& size) const; QColor getItemBGColor(const QStyle::State state) const; QPixmap getSubMenuPixmap(const QStyle::State state) const; QPixmap getIconPixmap(const QStyle::State state, const QIcon& icon, const QSize& size) const; }; #endif // POPUPMENUSTYLEH dtkwidget-2.0.7.2/src/platforms/windows/windows.pri000066400000000000000000000001241325435343100223440ustar00rootroot00000000000000HEADERS += \ $$PWD/popupmenustyle.h SOURCES += \ $$PWD/popupmenustyle.cpp dtkwidget-2.0.7.2/src/platforms/x11/000077500000000000000000000000001325435343100170605ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/platforms/x11/x11.pri000066400000000000000000000001011325435343100201750ustar00rootroot00000000000000HEADERS += \ $$PWD/xutil.h SOURCES += \ $$PWD/xutil.cpp dtkwidget-2.0.7.2/src/platforms/x11/xutil.cpp000066400000000000000000000467641325435343100207520ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "xutil.h" #include #include #include #include #include #include #include namespace XUtils { // From the WM spec #define _NET_WM_MOVERESIZE_INVALID -1 #define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 #define _NET_WM_MOVERESIZE_SIZE_TOP 1 #define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 #define _NET_WM_MOVERESIZE_SIZE_RIGHT 3 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4 #define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5 #define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6 #define _NET_WM_MOVERESIZE_SIZE_LEFT 7 #define _NET_WM_MOVERESIZE_MOVE 8 /* movement only */ #define _NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */ #define _NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */ #define _NET_WM_MOVERESIZE_CANCEL 11 /* cancel operation */ #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ #define _NET_WM_STATE_ADD 1 /* add/set property */ #define _NET_WM_STATE_TOGGLE 2 /* toggle property */ const char kAtomNameHidden[] = "_NET_WM_STATE_HIDDEN"; const char kAtomNameFullscreen[] = "_NET_WM_STATE_FULLSCREEN"; const char kAtomNameMaximizedHorz[] = "_NET_WM_STATE_MAXIMIZED_HORZ"; const char kAtomNameMaximizedVert[] = "_NET_WM_STATE_MAXIMIZED_VERT"; const char kAtomNameMoveResize[] = "_NET_WM_MOVERESIZE"; const char kAtomNameWmState[] = "_NET_WM_STATE"; const char kAtomNameWmStateAbove[] = "_NET_WM_STATE_ABOVE"; const char kAtomNameWmStateStaysOnTop[] = "_NET_WM_STATE_STAYS_ON_TOP"; const char kAtomNameWmSkipTaskbar[] = "_NET_WM_STATE_SKIP_TASKBAR"; const char kAtomNameWmSkipPager[] = "_NET_WM_STATE_SKIP_PAGER"; struct MwmHints { unsigned long flags; unsigned long functions; unsigned long decorations; long input_mode; unsigned long status; }; enum { MWM_HINTS_FUNCTIONS = (1L << 0), MWM_HINTS_DECORATIONS = (1L << 1), MWM_FUNC_ALL = (1L << 0), MWM_FUNC_RESIZE = (1L << 1), MWM_FUNC_MOVE = (1L << 2), MWM_FUNC_MINIMIZE = (1L << 3), MWM_FUNC_MAXIMIZE = (1L << 4), MWM_FUNC_CLOSE = (1L << 5), MWM_DECOR_ALL = (1L << 0), MWM_DECOR_BORDER = (1L << 1), MWM_DECOR_RESIZEH = (1L << 2), MWM_DECOR_TITLE = (1L << 3), MWM_DECOR_MENU = (1L << 4), MWM_DECOR_MINIMIZE = (1L << 5), MWM_DECOR_MAXIMIZE = (1L << 6), MWM_HINTS_INPUT_MODE = (1L << 2), MWM_INPUT_MODELESS = 0L, MWM_INPUT_PRIMARY_APPLICATION_MODAL = 1L, MWM_INPUT_FULL_APPLICATION_MODAL = 3L }; static int CornerEdge2WmGravity(const CornerEdge &ce) { switch (ce) { case CornerEdge::kTopLeft: return _NET_WM_MOVERESIZE_SIZE_TOPLEFT; case CornerEdge::kTop: return _NET_WM_MOVERESIZE_SIZE_TOP; case CornerEdge::kTopRight: return _NET_WM_MOVERESIZE_SIZE_TOPRIGHT; case CornerEdge::kRight: return _NET_WM_MOVERESIZE_SIZE_RIGHT; case CornerEdge::kBottomRight: return _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT; case CornerEdge::kBottom: return _NET_WM_MOVERESIZE_SIZE_BOTTOM; case CornerEdge::kBottomLeft: return _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT; case CornerEdge::kLeft: return _NET_WM_MOVERESIZE_SIZE_LEFT; default: return _NET_WM_MOVERESIZE_INVALID; } } static XCursorType CornerEdge2XCursor(const CornerEdge &ce) { switch (ce) { case CornerEdge::kTop: return XCursorType::kTop; case CornerEdge::kTopRight: return XCursorType::kTopRight; case CornerEdge::kRight: return XCursorType::kRight; case CornerEdge::kBottomRight: return XCursorType::kBottomRight; case CornerEdge::kBottom: return XCursorType::kBottom; case CornerEdge::kBottomLeft: return XCursorType::kBottomLeft; case CornerEdge::kLeft: return XCursorType::kLeft; case CornerEdge::kTopLeft: return XCursorType::kTopLeft; default: return XCursorType::kInvalid; } } void ChangeWindowMaximizedState(const QWidget *widget, int wm_state) { const auto display = QX11Info::display(); const auto screen = QX11Info::appScreen(); XEvent xev; memset(&xev, 0, sizeof(xev)); const Atom net_wm_state = XInternAtom(display, kAtomNameWmState, false); const Atom vertical_maximized = XInternAtom(display, kAtomNameMaximizedVert, false); const Atom horizontal_maximized = XInternAtom(display, kAtomNameMaximizedHorz, false); xev.xclient.type = ClientMessage; xev.xclient.message_type = net_wm_state; xev.xclient.display = display; xev.xclient.window = widget->winId(); xev.xclient.format = 32; xev.xclient.data.l[0] = wm_state; xev.xclient.data.l[1] = vertical_maximized; xev.xclient.data.l[2] = horizontal_maximized; xev.xclient.data.l[3] = 1; XSendEvent(display, QX11Info::appRootWindow(screen), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev); XFlush(display); } CornerEdge GetCornerEdge(const QWidget *widget, int x, int y, const QMargins &margins, int border_width) { QRect fullRect = widget->rect(); fullRect = fullRect.marginsRemoved(margins); unsigned int ce = static_cast(CornerEdge::kInvalid); if ((y - fullRect.top() >= -border_width) && (y < fullRect.top())) { ce = ce | static_cast(CornerEdge::kTop); } if ((x - fullRect.left() >= -border_width) && (x < fullRect.left())) { ce = ce | static_cast(CornerEdge::kLeft); } if ((y - fullRect.bottom() <= border_width) && (y > fullRect.bottom())) { ce = ce | static_cast(CornerEdge::kBottom); } if ((x - fullRect.right() <= border_width) && (x > fullRect.right())) { ce = ce | static_cast(CornerEdge::kRight); } return static_cast(ce); } void SendMoveResizeMessage(const QWidget *widget, Qt::MouseButton qbutton, int action) { const auto display = QX11Info::display(); const auto screen = QX11Info::appScreen(); int xbtn = qbutton == Qt::LeftButton ? Button1 : qbutton == Qt::RightButton ? Button3 : AnyButton; XEvent xev; memset(&xev, 0, sizeof(xev)); const Atom net_move_resize = XInternAtom(display, kAtomNameMoveResize, false); xev.xclient.type = ClientMessage; xev.xclient.message_type = net_move_resize; xev.xclient.display = display; xev.xclient.window = widget->winId(); xev.xclient.format = 32; const auto global_position = QCursor::pos(); xev.xclient.data.l[0] = global_position.x(); xev.xclient.data.l[1] = global_position.y(); xev.xclient.data.l[2] = action; xev.xclient.data.l[3] = xbtn; xev.xclient.data.l[4] = 0; XUngrabPointer(display, QX11Info::appTime()); XSendEvent(display, QX11Info::appRootWindow(screen), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev); XFlush(display); } bool IsCornerEdget(const QWidget *widget, int x, int y, const QMargins &margins, int border_width) { return GetCornerEdge(widget, x, y, margins, border_width) != CornerEdge::kInvalid; } void MoveWindow(const QWidget *widget, Qt::MouseButton qbutton) { SendMoveResizeMessage(widget, qbutton, _NET_WM_MOVERESIZE_MOVE); } void MoveResizeWindow(const QWidget *widget, Qt::MouseButton qbutton, int x, int y, const QMargins &margins, int border_width) { const CornerEdge ce = GetCornerEdge(widget, x, y, margins, border_width); if (ce != CornerEdge::kInvalid) { const int action = CornerEdge2WmGravity(ce); SendMoveResizeMessage(widget, qbutton, action); } } void ResetCursorShape(const QWidget *widget) { const auto display = QX11Info::display(); const WId window_id = widget->winId(); XUndefineCursor(display, window_id); XFlush(display); } bool SetCursorShape(const QWidget *widget, int cursor_id) { const auto display = QX11Info::display(); const WId window_id = widget->winId(); const Cursor cursor = XCreateFontCursor(display, cursor_id); if (!cursor) { qWarning() << "[ui]::SetCursorShape() call XCreateFontCursor() failed"; return false; } const int result = XDefineCursor(display, window_id, cursor); XFlush(display); return result == Success; } void ShowFullscreenWindow(const QWidget *widget, bool is_fullscreen) { const auto display = QX11Info::display(); const auto screen = QX11Info::appScreen(); XEvent xev; memset(&xev, 0, sizeof(xev)); const Atom net_wm_state = XInternAtom(display, kAtomNameWmState, false); const Atom fullscreen = XInternAtom(display, kAtomNameFullscreen, false); xev.xclient.type = ClientMessage; xev.xclient.message_type = net_wm_state; xev.xclient.display = display; xev.xclient.window = widget->winId(); xev.xclient.format = 32; if (is_fullscreen) { xev.xclient.data.l[0] = _NET_WM_STATE_ADD; } else { xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE; } xev.xclient.data.l[1] = fullscreen; xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 1; XSendEvent(display, QX11Info::appRootWindow(screen), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev ); XFlush(display); } void ShowMaximizedWindow(const QWidget *widget) { ChangeWindowMaximizedState(widget, _NET_WM_STATE_ADD); } void ShowMinimizedWindow(const QWidget *widget, bool minimized) { const auto display = QX11Info::display(); const auto screen = QX11Info::appScreen(); XEvent xev; memset(&xev, 0, sizeof(xev)); const Atom net_wm_state = XInternAtom(display, kAtomNameWmState, false); const Atom hidden = XInternAtom(display, kAtomNameHidden, false); xev.xclient.type = ClientMessage; xev.xclient.message_type = net_wm_state; xev.xclient.display = display; xev.xclient.window = widget->winId(); xev.xclient.format = 32; if (minimized) { xev.xclient.data.l[0] = _NET_WM_STATE_ADD; } else { xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE; } xev.xclient.data.l[1] = hidden; xev.xclient.data.l[2] = 0; xev.xclient.data.l[3] = 1; XSendEvent(display, QX11Info::appRootWindow(screen), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev ); XIconifyWindow(display, widget->winId(), screen); XFlush(display); } void ShowNormalWindow(const QWidget *widget) { ChangeWindowMaximizedState(widget, _NET_WM_STATE_REMOVE); } void ToggleMaximizedWindow(const QWidget *widget) { ChangeWindowMaximizedState(widget, _NET_WM_STATE_TOGGLE); } bool UpdateCursorShape(const QWidget *widget, int x, int y, const QMargins &margins, int border_width) { const CornerEdge ce = GetCornerEdge(widget, x, y, margins, border_width); const XCursorType x_cursor = CornerEdge2XCursor(ce); if (x_cursor != XCursorType::kInvalid) { return SetCursorShape(widget, static_cast(x_cursor)); } else { ResetCursorShape(widget); return false; } } void SkipTaskbarPager(const QWidget *widget) { Q_ASSERT(widget); const auto display = QX11Info::display(); const auto screen = QX11Info::appScreen(); const auto wmStateAtom = XInternAtom(display, kAtomNameWmState, false); const auto taskBarAtom = XInternAtom(display, kAtomNameWmSkipTaskbar, false); const auto noPagerAtom = XInternAtom(display, kAtomNameWmSkipPager, false); XEvent xev; memset(&xev, 0, sizeof(xev)); xev.xclient.type = ClientMessage; xev.xclient.message_type = wmStateAtom; xev.xclient.display = display; xev.xclient.window = widget->winId();; xev.xclient.format = 32; xev.xclient.data.l[0] = _NET_WM_STATE_ADD; xev.xclient.data.l[1] = taskBarAtom; xev.xclient.data.l[2] = noPagerAtom; xev.xclient.data.l[3] = 1; XSendEvent(display, QX11Info::appRootWindow(screen), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev); XFlush(display); } void SetStayOnTop(const QWidget *widget, bool on) { Q_ASSERT(widget); const auto display = QX11Info::display(); const auto screen = QX11Info::appScreen(); const auto wmStateAtom = XInternAtom(display, kAtomNameWmState, false); const auto stateAboveAtom = XInternAtom(display, kAtomNameWmStateAbove, false); const auto stateStaysOnTopAtom = XInternAtom(display, kAtomNameWmStateStaysOnTop, false); XEvent xev; memset(&xev, 0, sizeof(xev)); xev.xclient.type = ClientMessage; xev.xclient.message_type = wmStateAtom; xev.xclient.display = display; xev.xclient.window = widget->winId(); xev.xclient.format = 32; xev.xclient.data.l[0] = on ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; xev.xclient.data.l[1] = stateAboveAtom; xev.xclient.data.l[2] = stateStaysOnTopAtom; xev.xclient.data.l[3] = 1; XSendEvent(display, QX11Info::appRootWindow(screen), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev); XFlush(display); } void SetMouseTransparent(const QWidget *widget, bool on) { Q_ASSERT(widget); const auto display = QX11Info::display(); XRectangle XRect; XRect.x = 0; XRect.y = 0; int nRects = 0; if (on) { XRect.width = 0; XRect.height = 0; nRects = 0; } else { XRect.width = widget->width(); XRect.height = widget->height(); nRects = 1; } XShapeCombineRectangles(display, widget->winId(), ShapeInput, 0, 0, &XRect, nRects, ShapeSet, YXBanded); } void SetWindowExtents(const QWidget *widget, const QMargins &margins, const int resizeHandleWidth) { SetWindowExtents(widget->winId(), widget->rect(), margins, resizeHandleWidth); } void PropagateSizeHints(const QWidget *w) { const auto display = QX11Info::display(); XSizeHints *sh = XAllocSizeHints(); sh->flags = PPosition | PSize | PMinSize | PMaxSize | PResizeInc; sh->x = w->x(); sh->y = w->y(); sh->min_width = w->minimumWidth(); sh->min_height = w->minimumHeight(); sh->base_width = w->baseSize().width(); sh->base_height = w->baseSize().height(); sh->max_width = w->maximumWidth(); sh->max_height = w->maximumHeight(); sh->width_inc = w->sizeIncrement().width(); sh->height_inc = w->sizeIncrement().height(); XSetWMNormalHints(display, w->winId(), sh); XFree(sh); } void DisableResize(const QWidget *w) { Display *display = QX11Info::display(); Atom mwmHintsProperty = XInternAtom(display, "_MOTIF_WM_HINTS", 0); struct MwmHints *hints; unsigned char *wm_data; Atom wm_type; int wm_format; unsigned long wm_nitems, wm_bytes_after; XGetWindowProperty(display, w->winId(), mwmHintsProperty, 0, sizeof(MwmHints) / sizeof(long), false, AnyPropertyType, &wm_type, &wm_format, &wm_nitems, &wm_bytes_after, &wm_data); hints = (MwmHints *) wm_data; hints->flags |= MWM_HINTS_FUNCTIONS; if (hints->functions == MWM_FUNC_ALL) { hints->functions = MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE | MWM_FUNC_CLOSE; } else { hints->functions &= ~MWM_FUNC_RESIZE; hints->functions |= MWM_FUNC_CLOSE; } if (hints->decorations == MWM_DECOR_ALL) { hints->flags |= MWM_HINTS_DECORATIONS; hints->decorations = (MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MENU); } else { hints->decorations &= ~MWM_DECOR_RESIZEH; } XChangeProperty(display, w->winId(), mwmHintsProperty, mwmHintsProperty, 32, PropModeReplace, (unsigned char *)hints, 5); } void StartResizing(const QWidget *w, const QPoint &globalPoint, const CornerEdge &ce) { const auto display = QX11Info::display(); const auto winId = w->winId(); const auto screen = QX11Info::appScreen(); XEvent xev; const Atom netMoveResize = XInternAtom(display, "_NET_WM_MOVERESIZE", false); xev.xclient.type = ClientMessage; xev.xclient.message_type = netMoveResize; xev.xclient.display = display; xev.xclient.window = winId; xev.xclient.format = 32; xev.xclient.data.l[0] = globalPoint.x(); xev.xclient.data.l[1] = globalPoint.y(); xev.xclient.data.l[2] = CornerEdge2WmGravity(ce); xev.xclient.data.l[3] = Button1; xev.xclient.data.l[4] = 1; XUngrabPointer(display, QX11Info::appTime()); XSendEvent(display, QX11Info::appRootWindow(screen), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev); XFlush(display); } void CancelMoveWindow(const QWidget *widget, Qt::MouseButton qbutton) { SendMoveResizeMessage(widget, qbutton, _NET_WM_MOVERESIZE_CANCEL); } void SetWindowExtents(uint wid, const QRect &windowRect, const QMargins &margins, const int resizeHandleSize) { Atom frameExtents; unsigned long value[4] = { (unsigned long)(margins.left()), (unsigned long)(margins.right()), (unsigned long)(margins.top()), (unsigned long)(margins.bottom()) }; frameExtents = XInternAtom(QX11Info::display(), "_GTK_FRAME_EXTENTS", False); if (frameExtents == None) { qWarning() << "Failed to create atom with name DEEPIN_WINDOW_SHADOW"; return; } XChangeProperty(QX11Info::display(), wid, frameExtents, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)value, 4); QRect tmp_rect = windowRect; tmp_rect -= margins; XRectangle contentXRect; contentXRect.x = 0; contentXRect.y = 0; contentXRect.width = tmp_rect.width() + resizeHandleSize * 2; contentXRect.height = tmp_rect.height() + resizeHandleSize * 2; XShapeCombineRectangles(QX11Info::display(), wid, ShapeInput, margins.left() - resizeHandleSize, margins.top() - resizeHandleSize, &contentXRect, 1, ShapeSet, YXBanded); } } dtkwidget-2.0.7.2/src/platforms/x11/xutil.h000066400000000000000000000055571325435343100204120ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include QT_BEGIN_NAMESPACE class QWidget; class QPoint; class QMargins; class QRect; QT_END_NAMESPACE namespace XUtils { enum class CornerEdge { kInvalid = 0, kTop = 1, kRight = 2, kBottom = 4, kLeft = 8, kTopLeft = 1 | 8, kTopRight = 1 | 2, kBottomLeft = 4 | 8, kBottomRight = 4 | 2, }; enum class XCursorType { kInvalid = -1, kArrow = 2, kTop = 138, kTopRight = 136, kRight = 96, kBottomRight = 14, kBottom = 16, kBottomLeft = 12, kLeft = 70, kTopLeft = 134, }; void ChangeWindowMaximizedState(const QWidget *widget, int wm_state); CornerEdge GetCornerEdge(const QWidget *widget, int x, int y, const QMargins &margins, int border_width); bool UpdateCursorShape(const QWidget *widget, int x, int y, const QMargins &margins, int border_width); bool IsCornerEdget(const QWidget *widget, int x, int y, const QMargins &margins, int border_width); void MoveResizeWindow(const QWidget *widget, Qt::MouseButton qbutton, int x, int y, const QMargins &margins, int border_width); void StartResizing(const QWidget *w, const QPoint &globalPoint, const CornerEdge &ce); void SendMoveResizeMessage(const QWidget *widget, Qt::MouseButton qbutton, int action); void MoveWindow(const QWidget *widget, Qt::MouseButton qbutton); void CancelMoveWindow(const QWidget *widget, Qt::MouseButton qbutton); void ResetCursorShape(const QWidget *widget); bool SetCursorShape(const QWidget *widget, int cursor_id); void ShowFullscreenWindow(const QWidget *widget, bool is_fullscreen); void ShowMaximizedWindow(const QWidget *widget); void ShowMinimizedWindow(const QWidget *widget, bool minimized); void ShowNormalWindow(const QWidget *widget); void ToggleMaximizedWindow(const QWidget *widget); void SkipTaskbarPager(const QWidget *widget); void SetStayOnTop(const QWidget *widget, bool on); void SetMouseTransparent(const QWidget *widget, bool on); void SetWindowExtents(const QWidget *widget, const QMargins &margins, const int resizeHandlSize); void SetWindowExtents(uint wid, const QRect &windowRect, const QMargins &margins, const int resizeHandleSize); void PropagateSizeHints(const QWidget *w); void DisableResize(const QWidget *w); } dtkwidget-2.0.7.2/src/src.pro000066400000000000000000000057661325435343100157670ustar00rootroot00000000000000TARGET = dtkwidget TEMPLATE = lib QT += dtkcore # TODO: replace config.pri with dtk_build include($$PWD/config.pri) load(dtk_build) CONFIG += internal_module QT += multimedia multimediawidgets concurrent greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets widgets-private # Qt >= 5.8 greaterThan(QT_MAJOR_VERSION, 5)|greaterThan(QT_MINOR_VERSION, 7): QT += gui-private else: QT += platformsupport-private } linux* { QT += x11extras dbus } mac* { QT += svg dbus DEFINES += DTK_TITLE_DRAG_WINDOW } win* { QT += svg DEFINES += DTK_TITLE_DRAG_WINDOW } !isEmpty(DTK_STATIC_LIB){ DEFINES += DTK_STATIC_LIB CONFIG += staticlib } load(configure) qtCompileTest(libdframeworkdbus) { DEFINES += DFRAMEWORKDBUS_API_XEVENTMONITOR } else { CONFIG -= no_keywords } HEADERS += dtkwidget_global.h includes.path = $${DTK_INCLUDEPATH}/DWidget includes.files += \ $$PWD/dtkwidget_global.h\ $$PWD/DtkWidgets\ $$PWD/dtkwidget_config.h include($$PWD/util/util.pri) include($$PWD/widgets/widgets.pri) linux* { includes.files += $$PWD/platforms/linux/*.h } win32* { includes.files += $$PWD/platforms/windows/*.h } # add translations TRANSLATIONS += $$PWD/../translations/$${TARGET}2.ts \ $$PWD/../translations/$${TARGET}2_zh_CN.ts translations.path = $$PREFIX/share/$${TARGET}/translations translations.files = $$PWD/../translations/*.qm INSTALLS += translations # create DtkWidgets file defineTest(containIncludeFiles) { header = $$absolute_path($$ARGS) header_dir = $$quote($$dirname(header)) for (file, includes.files) { file_ap = $$absolute_path($$file) file_dir = $$quote($$dirname(file_ap)) isEqual(file_dir, $$header_dir):return(true) } return(false) } defineTest(updateDtkWidgetsFile) { dtkwidgets_include_files = $$HEADERS dtkwidgets_file_content = $$quote($${LITERAL_HASH}ifndef DTK_WIDGETS_MODULE_H) dtkwidgets_file_content += $$quote($${LITERAL_HASH}define DTK_WIDGETS_MODULE_H) for(header, dtkwidgets_include_files) { containIncludeFiles($$header) { dtkwidgets_file_content += $$quote($${LITERAL_HASH}include \"$$basename(header)\") } } dtkwidgets_file_content += $$quote($${LITERAL_HASH}endif) !write_file($$PWD/DtkWidgets, dtkwidgets_file_content):return(false) return(true) } !updateDtkWidgetsFile():warning(Cannot create "DtkWidgets" header file) # create dtkwidget_config.h file defineTest(updateDtkWidgetConfigFile) { for(file, includes.files) { file = $$quote($$basename(file)) !isEqual(file, DtkWidgets):contains(file, D[A-Za-z0-9_]+) { dtkwidget_config_content += $$quote($${LITERAL_HASH}define DTKWIDGET_CLASS_$$file) } } !write_file($$PWD/dtkwidget_config.h, dtkwidget_config_content):return(false) return(true) } !updateDtkWidgetConfigFile():warning(Cannot create "dtkwidget_config.h" header file) INSTALLS += includes target load(dtk_cmake) QMAKE_PKGCONFIG_REQUIRES += dtkcore load(dtk_module) dtkwidget-2.0.7.2/src/util/000077500000000000000000000000001325435343100154155ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/util/DDesktopServices000066400000000000000000000000361325435343100205600ustar00rootroot00000000000000#include "ddesktopservices.h" dtkwidget-2.0.7.2/src/util/DFileIconProvider000066400000000000000000000000371325435343100206470ustar00rootroot00000000000000#include "dfileiconprovider.h" dtkwidget-2.0.7.2/src/util/DHiDPIHelper000066400000000000000000000000321325435343100174740ustar00rootroot00000000000000#include "dhidpihelper.h" dtkwidget-2.0.7.2/src/util/DSvgRenderer000066400000000000000000000000321325435343100176650ustar00rootroot00000000000000#include "dsvgrenderer.h" dtkwidget-2.0.7.2/src/util/DThumbnailProvider000066400000000000000000000000401325435343100210740ustar00rootroot00000000000000#include "dthumbnailprovider.h" dtkwidget-2.0.7.2/src/util/DTrashManager000066400000000000000000000000331325435343100200140ustar00rootroot00000000000000#include "dtrashmanager.h" dtkwidget-2.0.7.2/src/util/DWidgetUtil000066400000000000000000000000311325435343100175170ustar00rootroot00000000000000#include "dwidgetutil.h" dtkwidget-2.0.7.2/src/util/DWindowManagerHelper000066400000000000000000000000421325435343100213420ustar00rootroot00000000000000#include "dwindowmanagerhelper.h" dtkwidget-2.0.7.2/src/util/ddesktopservices.h000066400000000000000000000050551325435343100211540ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DDESKTOPSERVICES_H #define DDESKTOPSERVICES_H #include "dtkwidget_global.h" #include DWIDGET_BEGIN_NAMESPACE class DDesktopServices { public: #ifdef Q_OS_LINUX enum SystemSoundEffect { SSE_Notifications, SSE_Screenshot, SSE_EmptyTrash, SSE_SendFileComplete }; #endif static bool showFolder(QString localFilePath, const QString &startupId = QString()); static bool showFolders(const QList localFilePaths, const QString &startupId = QString()); static bool showFolder(QUrl url, const QString &startupId = QString()); static bool showFolders(const QList urls, const QString &startupId = QString()); static bool showFileItemPropertie(QString localFilePath, const QString &startupId = QString()); static bool showFileItemProperties(const QList localFilePaths, const QString &startupId = QString()); static bool showFileItemPropertie(QUrl url, const QString &startupId = QString()); static bool showFileItemProperties(const QList urls, const QString &startupId = QString()); static bool showFileItem(QString localFilePath, const QString &startupId = QString()); static bool showFileItems(const QList localFilePaths, const QString &startupId = QString()); static bool showFileItem(QUrl url, const QString &startupId = QString()); static bool showFileItems(const QList urls, const QString &startupId = QString()); static bool trash(QString localFilePath); static bool trash(const QList localFilePaths); static bool trash(QUrl urlstartupId); static bool trash(const QList urls); #ifdef Q_OS_LINUX static bool playSystemSoundEffect(const SystemSoundEffect &effect); static bool playSystemSoundEffect(const QString &name); #endif static QString errorMessage(); }; DWIDGET_END_NAMESPACE #endif // DDESKTOPSERVICES_H dtkwidget-2.0.7.2/src/util/ddesktopservices_linux.cpp000066400000000000000000000141211325435343100227200ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "ddesktopservices.h" #include #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE #define EASY_CALL_DBUS(name)\ QDBusInterface *interface = fileManager1DBusInterface();\ return interface && interface->call(#name, urls2uris(urls), startupId).type() != QDBusMessage::ErrorMessage; static QDBusInterface *fileManager1DBusInterface() { static QDBusInterface interface(QStringLiteral("org.freedesktop.FileManager1"), QStringLiteral("/org/freedesktop/FileManager1"), QStringLiteral("org.freedesktop.FileManager1")); return &interface; } static QStringList urls2uris(const QList &urls) { QStringList list; list.reserve(urls.size()); for (const QUrl &url : urls) { list << url.toString(); } return list; } static QList path2urls(const QList &paths) { QList list; list.reserve(paths.size()); for (const QString &path : paths) { list << QUrl::fromLocalFile(path); } return list; } static QMediaPlayer *soundEffectPlayer() { static QMediaPlayer *player = Q_NULLPTR; if (!player) { player = new QMediaPlayer; player->setVolume(70); } return player; } static QString soundEffectFilePath(const QString &name) { // TODO: super simple version of sound theme file search shema :) // will need to be replaced by more advanced approch like libcanberra. const QString temp = QString("/usr/share/sounds/deepin/stereo/%1.ogg").arg(name); if (QFile::exists(temp)) { return temp; } else { return QString(); } } static bool systemSoundEffectEnabled(const QString &name) { QGSettings settings("com.deepin.dde.sound-effect"); const bool effEnabled = settings.get("enabled").toBool(); if (effEnabled) { const QStringList list = settings.keys(); if (!list.contains(name)) { return false; } return settings.get(name).toBool(); } return effEnabled; } bool DDesktopServices::showFolder(QString localFilePath, const QString &startupId) { return showFolder(QUrl::fromLocalFile(localFilePath), startupId); } bool DDesktopServices::showFolders(const QList localFilePaths, const QString &startupId) { return showFolders(path2urls(localFilePaths), startupId); } bool DDesktopServices::showFolder(QUrl url, const QString &startupId) { return showFolders(QList() << url, startupId); } bool DDesktopServices::showFolders(const QList urls, const QString &startupId) { EASY_CALL_DBUS(ShowFolders) } bool DDesktopServices::showFileItemPropertie(QString localFilePath, const QString &startupId) { return showFileItemPropertie(QUrl::fromLocalFile(localFilePath), startupId); } bool DDesktopServices::showFileItemProperties(const QList localFilePaths, const QString &startupId) { return showFileItemProperties(path2urls(localFilePaths), startupId); } bool DDesktopServices::showFileItemPropertie(QUrl url, const QString &startupId) { return showFileItemProperties(QList() << url, startupId); } bool DDesktopServices::showFileItemProperties(const QList urls, const QString &startupId) { EASY_CALL_DBUS(ShowItemProperties) } bool DDesktopServices::showFileItem(QString localFilePath, const QString &startupId) { return showFileItem(QUrl::fromLocalFile(localFilePath), startupId); } bool DDesktopServices::showFileItems(const QList localFilePaths, const QString &startupId) { return showFileItems(path2urls(localFilePaths), startupId); } bool DDesktopServices::showFileItem(QUrl url, const QString &startupId) { return showFileItems(QList() << url, startupId); } bool DDesktopServices::showFileItems(const QList urls, const QString &startupId) { EASY_CALL_DBUS(ShowItems) } bool DDesktopServices::trash(QString localFilePath) { return trash(QUrl::fromLocalFile(localFilePath)); } bool DDesktopServices::trash(const QList localFilePaths) { return trash(path2urls(localFilePaths)); } bool DDesktopServices::trash(QUrl url) { return trash(QList() << url); } bool DDesktopServices::trash(const QList urls) { QDBusInterface *interface = fileManager1DBusInterface(); return interface && interface->call("Trash", urls2uris(urls)).type() != QDBusMessage::ErrorMessage; } bool DDesktopServices::playSystemSoundEffect(const DDesktopServices::SystemSoundEffect &effect) { switch (effect) { case SSE_Notifications: return playSystemSoundEffect("message"); case SSE_Screenshot: return playSystemSoundEffect("camera-shutter"); case SSE_EmptyTrash: return playSystemSoundEffect("trash-empty"); case SSE_SendFileComplete: return playSystemSoundEffect("complete-copy"); default: return false; } } bool DDesktopServices::playSystemSoundEffect(const QString &name) { if (!systemSoundEffectEnabled(name)) { return false; } const QString path = soundEffectFilePath(name); if (path.isEmpty()) { return false; } QMediaPlayer *player = soundEffectPlayer(); player->setMedia(QUrl::fromLocalFile(path)); player->play(); return true; } QString DDesktopServices::errorMessage() { return fileManager1DBusInterface()->lastError().message(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/ddesktopservices_win.cpp000066400000000000000000000070241325435343100223620ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "ddesktopservices.h" DWIDGET_BEGIN_NAMESPACE static QStringList urls2uris(const QList &urls) { QStringList list; list.reserve(urls.size()); for (const QUrl url : urls) { list << url.toString(); } return list; } static QList path2urls(const QList &paths) { QList list; list.reserve(paths.size()); for (const QString &path : paths) { list << QUrl::fromLocalFile(path); } return list; } bool DDesktopServices::showFolder(QString localFilePath, const QString &startupId) { Q_UNUSED(localFilePath); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFolders(const QList localFilePaths, const QString &startupId) { Q_UNUSED(localFilePaths); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFolder(QUrl url, const QString &startupId) { Q_UNUSED(url); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFolders(const QList urls, const QString &startupId) { Q_UNUSED(urls); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFileItemPropertie(QString localFilePath, const QString &startupId) { Q_UNUSED(localFilePath); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFileItemProperties(const QList localFilePaths, const QString &startupId) { Q_UNUSED(localFilePaths); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFileItemPropertie(QUrl url, const QString &startupId) { Q_UNUSED(url); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFileItemProperties(const QList urls, const QString &startupId) { Q_UNUSED(urls); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFileItem(QString localFilePath, const QString &startupId) { Q_UNUSED(localFilePath); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFileItems(const QList localFilePaths, const QString &startupId) { Q_UNUSED(localFilePaths); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFileItem(QUrl url, const QString &startupId) { Q_UNUSED(url); Q_UNUSED(startupId); return false; } bool DDesktopServices::showFileItems(const QList urls, const QString &startupId) { Q_UNUSED(urls); Q_UNUSED(startupId); return false; } bool DDesktopServices::trash(QString localFilePath) { Q_UNUSED(localFilePath); return false; } bool DDesktopServices::trash(const QList localFilePaths) { Q_UNUSED(localFilePaths); return false; } bool DDesktopServices::trash(QUrl url) { Q_UNUSED(url); return false; } bool DDesktopServices::trash(const QList urls) { Q_UNUSED(urls); return false; } QString DDesktopServices::errorMessage() { return QString(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/desktop.pri000066400000000000000000000012071325435343100176020ustar00rootroot00000000000000HEADERS += \ $$PWD/ddesktopservices.h \ $$PWD/dtrashmanager.h linux { qtHaveModule(dbus) { QT += dbus SOURCES += $$PWD/ddesktopservices_linux.cpp } CONFIG += link_pkgconfig PKGCONFIG += gsettings-qt SOURCES += \ $$PWD/dtrashmanager_linux.cpp } else:win* { SOURCES += \ $$PWD/ddesktopservices_win.cpp \ $$PWD/dtrashmanager_win.cpp } else:mac* { SOURCES += \ $$PWD/ddesktopservices_win.cpp \ $$PWD/dtrashmanager_win.cpp } includes.files += $$PWD/*.h includes.files += $$PWD/*.cpp includes.files += \ $$PWD/DDesktopServices \ $$PWD/DTrashManager dtkwidget-2.0.7.2/src/util/dfileiconprovider.cpp000066400000000000000000000124001325435343100216250ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "dfileiconprovider.h" #include #include #include #include #ifdef USE_GTK_PLUS_2_0 #include #undef signals // Collides with GTK symbols #include #endif DWIDGET_BEGIN_NAMESPACE #ifdef USE_GTK_PLUS_2_0 typedef enum { GNOME_ICON_LOOKUP_FLAGS_NONE = 0, GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1 << 0, GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1 << 1, GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1 << 2 } GnomeIconLookupFlags; typedef enum { GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0, GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1 << 0 } GnomeIconLookupResultFlags; struct GnomeThumbnailFactory; typedef gboolean(*Ptr_gnome_vfs_init)(void); typedef char *(*Ptr_gnome_icon_lookup_sync)( GtkIconTheme *icon_theme, GnomeThumbnailFactory *, const char *file_uri, const char *custom_icon, GnomeIconLookupFlags flags, GnomeIconLookupResultFlags *result); typedef GtkIconTheme *(*Ptr_gtk_icon_theme_get_default)(void); #endif class DFileIconProviderPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DFileIconProviderPrivate(DFileIconProvider *qq); void init(); QIcon getFilesystemIcon(const QFileInfo &info) const; QIcon fromTheme(QString iconName) const; D_DECLARE_PUBLIC(DFileIconProvider) #ifdef USE_GTK_PLUS_2_0 static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync; static Ptr_gnome_vfs_init gnome_vfs_init; static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default; }; Ptr_gnome_icon_lookup_sync DFileIconProviderPrivate::gnome_icon_lookup_sync; Ptr_gnome_vfs_init DFileIconProviderPrivate::gnome_vfs_init; Ptr_gtk_icon_theme_get_default DFileIconProviderPrivate::gtk_icon_theme_get_default; #else }; #endif DFileIconProviderPrivate::DFileIconProviderPrivate(DFileIconProvider *qq) : DObjectPrivate(qq) { init(); } void DFileIconProviderPrivate::init() { #ifdef USE_GTK_PLUS_2_0 gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLatin1String("gnomeui-2"), 0, "gnome_icon_lookup_sync"); gnome_vfs_init = (Ptr_gnome_vfs_init)QLibrary::resolve(QLatin1String("gnomevfs-2"), 0, "gnome_vfs_init"); gtk_icon_theme_get_default = (Ptr_gtk_icon_theme_get_default)QLibrary::resolve(QLatin1String("gtk-x11-2.0"), 0, "gtk_icon_theme_get_default"); #endif } QIcon DFileIconProviderPrivate::getFilesystemIcon(const QFileInfo &info) const { #ifdef USE_GTK_PLUS_2_0 if (gnome_vfs_init && gnome_icon_lookup_sync && gtk_icon_theme_get_default) { gnome_vfs_init(); GtkIconTheme *theme = gtk_icon_theme_get_default(); QByteArray fileurl = QUrl::fromLocalFile(info.absoluteFilePath()).toEncoded(); char *icon_name = gnome_icon_lookup_sync(theme, NULL, fileurl.data(), NULL, GNOME_ICON_LOOKUP_FLAGS_NONE, NULL); QString iconName = QString::fromUtf8(icon_name); g_free(icon_name); if (iconName.startsWith(QLatin1Char('/'))) { return QIcon(iconName); } return fromTheme(iconName); } #endif const QMimeType &db = QMimeDatabase().mimeTypeForFile(info); const QIcon &icon = fromTheme(db.iconName()); if (!icon.isNull()) { return icon; } return fromTheme(db.genericIconName()); } QIcon DFileIconProviderPrivate::fromTheme(QString iconName) const { QIcon icon = QIcon::fromTheme(iconName); if (Q_LIKELY(!icon.isNull())) { return icon; } if (iconName == "application-vnd.debian.binary-package") { iconName = "application-x-deb"; } else if (iconName == "application-vnd.rar") { iconName = "application-zip"; } else if (iconName == "application-vnd.ms-htmlhelp") { iconName = "chmsee"; } else { return icon; } icon = QIcon::fromTheme(iconName); return icon; } Q_GLOBAL_STATIC(DFileIconProvider, globalFIP) DFileIconProvider::DFileIconProvider() : DObject(*new DFileIconProviderPrivate(this)) { } DFileIconProvider::~DFileIconProvider() { } DFileIconProvider *DFileIconProvider::globalProvider() { return globalFIP; } QIcon DFileIconProvider::icon(const QFileInfo &info) const { Q_D(const DFileIconProvider); return d->getFilesystemIcon(info); } QIcon DFileIconProvider::icon(const QFileInfo &info, const QIcon &feedback) const { const QIcon &icon = this->icon(info); if (icon.isNull()) { return feedback; } return icon; } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dfileiconprovider.h000066400000000000000000000025241325435343100213000ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DFILEICONPROVIDER_H #define DFILEICONPROVIDER_H #include #include "dtkwidget_global.h" #include DWIDGET_BEGIN_NAMESPACE class DFileIconProviderPrivate; class DFileIconProvider : public QFileIconProvider, public DTK_CORE_NAMESPACE::DObject { public: DFileIconProvider(); ~DFileIconProvider(); static DFileIconProvider *globalProvider(); QIcon icon(const QFileInfo &info) const Q_DECL_OVERRIDE; QIcon icon(const QFileInfo &info, const QIcon &feedback) const; private: D_DECLARE_PRIVATE(DFileIconProvider) Q_DISABLE_COPY(DFileIconProvider) }; DWIDGET_END_NAMESPACE #endif // DFILEICONPROVIDER_H dtkwidget-2.0.7.2/src/util/dhidpihelper.cpp000066400000000000000000000021631325435343100205640ustar00rootroot00000000000000#include "dhidpihelper.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE /*! * \class DHiDPIHelper * \brief The DHiDPIHelper class provides helper to help applications support hiDPI. */ /*! * \brief DHiDPIHelper::loadNxPixmap loads the suitable @Nx image. * \param fileName is the original resource file name. * \return the hiDPI ready QPixmap. */ QPixmap DHiDPIHelper::loadNxPixmap(const QString &fileName) { qreal sourceDevicePixelRatio = 1.0; qreal devicePixelRatio = qApp->devicePixelRatio(); QPixmap pixmap; if (!qFuzzyCompare(sourceDevicePixelRatio, devicePixelRatio)) { QImageReader reader; reader.setFileName(qt_findAtNxFile(fileName, devicePixelRatio, &sourceDevicePixelRatio)); if (reader.canRead()) { reader.setScaledSize(reader.size() * (devicePixelRatio / sourceDevicePixelRatio)); pixmap = QPixmap::fromImage(reader.read()); pixmap.setDevicePixelRatio(devicePixelRatio); } } else { pixmap.load(fileName); } return pixmap; } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dhidpihelper.h000066400000000000000000000003621325435343100202300ustar00rootroot00000000000000#ifndef DHIDPIHELPER_H #define DHIDPIHELPER_H #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DHiDPIHelper { public: static QPixmap loadNxPixmap(const QString &fileName); }; DWIDGET_END_NAMESPACE #endif // DHIDPIHELPER_H dtkwidget-2.0.7.2/src/util/dregionmonitor.cpp000066400000000000000000000114541325435343100211650ustar00rootroot00000000000000#include "dregionmonitor.h" #include "private/dregionmonitor_p.h" #include #include #include DWIDGET_BEGIN_NAMESPACE DRegionMonitor::DRegionMonitor(QObject *parent) : QObject(parent), DObject(*new DRegionMonitorPrivate(this)) { D_D(DRegionMonitor); d->init(); } bool DRegionMonitor::registered() const { D_DC(DRegionMonitor); return !d->registerKey.isEmpty(); } QRegion DRegionMonitor::watchedRegion() const { D_DC(DRegionMonitor); return d->watchedRegion; } void DRegionMonitor::registerRegion() { if (registered()) { qWarning() << "region already registered!"; return; } D_D(DRegionMonitor); d->registerMonitorRegion(); } void DRegionMonitor::unregisterRegion() { D_D(DRegionMonitor); d->unregisterMonitorRegion(); } void DRegionMonitor::setWatchedRegion(const QRegion ®ion) { D_D(DRegionMonitor); d->watchedRegion = region; if (registered()) d->registerMonitorRegion(); } DRegionMonitorPrivate::DRegionMonitorPrivate(DRegionMonitor *q) : DObjectPrivate(q) #ifdef DFRAMEWORKDBUS_API_XEVENTMONITOR , eventInter(new XEventMonitor("com.deepin.api.XEventMonitor", "/com/deepin/api/XEventMonitor", QDBusConnection::sessionBus())) #else , eventInter(new XMousAreaInter("com.deepin.api.XMouseArea", "/com/deepin/api/XMouseArea", QDBusConnection::sessionBus())) #endif { } DRegionMonitorPrivate::~DRegionMonitorPrivate() { if (registered()) unregisterMonitorRegion(); eventInter->deleteLater(); } void DRegionMonitorPrivate::init() { D_Q(DRegionMonitor); QObject::connect(eventInter, SIGNAL(ButtonPress(int,int,int,QString)), q, SLOT(_q_ButtonPress(const int, const int, const int, const QString&))); QObject::connect(eventInter, SIGNAL(ButtonRelease(int,int,int,QString)), q, SLOT(_q_ButtonRelease(const int, const int, const int, const QString&))); QObject::connect(eventInter, SIGNAL(CursorMove(int,int,QString)), q, SLOT(_q_CursorMove(const int, const int, const QString&))); QObject::connect(eventInter, SIGNAL(KeyPress(QString,int,int,QString)), q, SLOT(_q_KeyPress(const QString&, const int, const int, const QString&))); QObject::connect(eventInter, SIGNAL(KeyRelease(QString,int,int,QString)), q, SLOT(_q_KeyRelease(const QString&, const int, const int, const QString&))); } void DRegionMonitorPrivate::registerMonitorRegion() { if (registered()) unregisterMonitorRegion(); if (watchedRegion.isEmpty()) { registerKey = eventInter->RegisterFullScreen(); } else { const QRect r = watchedRegion.boundingRect(); const int x1 = r.x(); const int y1 = r.y(); const int x2 = x1 + r.width(); const int y2 = y1 + r.height(); // TODO: const int flags = Motion | Button | Key; registerKey = eventInter->RegisterArea(x1, y1, x2, y2, flags); } } void DRegionMonitorPrivate::unregisterMonitorRegion() { if (registerKey.isEmpty()) return; eventInter->UnregisterArea(registerKey); registerKey.clear(); } void DRegionMonitorPrivate::_q_ButtonPress(const int flag, const int x, const int y, const QString &key) { if (registerKey != key) return; D_Q(DRegionMonitor); Q_EMIT q->buttonPress(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio()), flag); } void DRegionMonitorPrivate::_q_ButtonRelease(const int flag, const int x, const int y, const QString &key) { if (registerKey != key) return; D_Q(DRegionMonitor); Q_EMIT q->buttonRelease(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio()), flag); } void DRegionMonitorPrivate::_q_CursorMove(const int x, const int y, const QString &key) { if (registerKey != key) return; D_Q(DRegionMonitor); Q_EMIT q->cursorMove(deviceScaledCoordinate(QPoint(x, y), qApp->devicePixelRatio())); } void DRegionMonitorPrivate::_q_KeyPress(const QString &keyname, const int x, const int y, const QString &key) { if (registerKey != key) return; Q_UNUSED(x); Q_UNUSED(y); D_Q(DRegionMonitor); Q_EMIT q->keyPress(keyname); } void DRegionMonitorPrivate::_q_KeyRelease(const QString &keyname, const int x, const int y, const QString &key) { if (registerKey != key) return; Q_UNUSED(x); Q_UNUSED(y); D_Q(DRegionMonitor); Q_EMIT q->keyRelease(keyname); } const QPoint DRegionMonitorPrivate::deviceScaledCoordinate(const QPoint &p, const double ratio) const { for (const auto *s : qApp->screens()) { const QRect &g(s->geometry()); const QRect realRect(g.topLeft(), g.size() * ratio); if (realRect.contains(p)) return QPoint(realRect.topLeft() + (p - realRect.topLeft()) / ratio); } return p / ratio; } #include "moc_dregionmonitor.cpp" DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dregionmonitor.h000066400000000000000000000031341325435343100206260ustar00rootroot00000000000000#ifndef DREGIONMONITOR_H #define DREGIONMONITOR_H #include "dobject.h" #include "dtkwidget_global.h" #include DWIDGET_BEGIN_NAMESPACE class DRegionMonitorPrivate; class DRegionMonitor : public QObject, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT D_DECLARE_PRIVATE(DRegionMonitor) Q_DISABLE_COPY(DRegionMonitor) public: explicit DRegionMonitor(QObject *parent = nullptr); enum WatchedFlags { Button_Left = 1, Button_Right = 3, }; bool registered() const; QRegion watchedRegion() const; Q_SIGNALS: void buttonPress(const QPoint &p, const int flag) const; void buttonRelease(const QPoint &p, const int flag) const; void cursorMove(const QPoint &p) const; void keyPress(const QString &keyname) const; void keyRelease(const QString &keyname) const; public Q_SLOTS: void registerRegion(); inline void registerRegion(const QRegion ®ion) { setWatchedRegion(region); registerRegion(); } void unregisterRegion(); void setWatchedRegion(const QRegion ®ion); private: Q_PRIVATE_SLOT(d_func(), void _q_ButtonPress(const int, const int, const int, const QString&)) Q_PRIVATE_SLOT(d_func(), void _q_ButtonRelease(const int, const int, const int, const QString&)) Q_PRIVATE_SLOT(d_func(), void _q_CursorMove(const int, const int, const QString &)) Q_PRIVATE_SLOT(d_func(), void _q_KeyPress(const QString &, const int, const int, const QString &)) Q_PRIVATE_SLOT(d_func(), void _q_KeyRelease(const QString &, const int, const int, const QString &)) }; DWIDGET_END_NAMESPACE #endif // DREGIONMONITOR_H dtkwidget-2.0.7.2/src/util/dsvgrenderer.cpp000066400000000000000000000124671325435343100206250ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "dsvgrenderer.h" #include "dobject_p.h" #include #include #include #include DCORE_USE_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DSvgRendererPrivate : public DObjectPrivate { public: DSvgRendererPrivate(DObject *qq); RsvgHandle *handle = NULL; QSize defaultSize; mutable QRectF viewBox; }; DSvgRendererPrivate::DSvgRendererPrivate(DObject *qq) : DObjectPrivate(qq) { } DSvgRenderer::DSvgRenderer(QObject *parent) : QObject(parent) , DObject(*new DSvgRendererPrivate(this)) { } DSvgRenderer::DSvgRenderer(const QString &filename, QObject *parent) : DSvgRenderer(parent) { load(filename); } DSvgRenderer::DSvgRenderer(const QByteArray &contents, QObject *parent) : DSvgRenderer(parent) { load(contents); } DSvgRenderer::~DSvgRenderer() { D_D(DSvgRenderer); if (d->handle) g_object_unref(d->handle); } bool DSvgRenderer::isValid() const { D_DC(DSvgRenderer); return d->handle; } QSize DSvgRenderer::defaultSize() const { D_DC(DSvgRenderer); return d->defaultSize; } QRect DSvgRenderer::viewBox() const { D_DC(DSvgRenderer); return d->handle ? d->viewBox.toRect() : QRect(); } QRectF DSvgRenderer::viewBoxF() const { D_DC(DSvgRenderer); return d->handle ? d->viewBox : QRectF(); } void DSvgRenderer::setViewBox(const QRect &viewbox) { setViewBox(QRectF(viewbox)); } void DSvgRenderer::setViewBox(const QRectF &viewbox) { D_D(DSvgRenderer); if (d->handle) d->viewBox = viewbox; } QRectF DSvgRenderer::boundsOnElement(const QString &id) const { D_DC(DSvgRenderer); if (!d->handle) return QRectF(); const QByteArray &id_data = id.toUtf8(); RsvgDimensionData dimension_data; if (!rsvg_handle_get_dimensions_sub(d->handle, &dimension_data, id_data.constData())) return QRectF(); RsvgPositionData pos_data; if (!rsvg_handle_get_position_sub(d->handle, &pos_data, id_data.constData())) return QRectF(); return QRectF(pos_data.x, pos_data.y, dimension_data.width, dimension_data.height); } bool DSvgRenderer::elementExists(const QString &id) const { D_DC(DSvgRenderer); if (!d->handle) return false; return rsvg_handle_has_sub(d->handle, id.toUtf8().constData()); } QPixmap DSvgRenderer::render(const QString &svgPath, const QSize &sz) { QImage ret(sz, QImage::Format_ARGB32); ret.fill(Qt::transparent); QPainter ptr(&ret); DSvgRenderer rdr(svgPath); rdr.render(&ptr); return QPixmap::fromImage(ret); } bool DSvgRenderer::load(const QString &filename) { QFile file(filename); if (file.open(QIODevice::ReadOnly)) { return load(file.readAll()); } return false; } bool DSvgRenderer::load(const QByteArray &contents) { D_D(DSvgRenderer); if (d->handle) { g_object_unref(d->handle); d->handle = NULL; } GError *error = 0; d->handle = rsvg_handle_new_from_data((const guint8*)contents.constData(), contents.length(), &error); if (error) { qWarning("DSvgRenderer::load: %s", error->message); g_error_free(error); return false; } RsvgDimensionData rsvg_data; rsvg_handle_get_dimensions(d->handle, &rsvg_data); d->defaultSize.setWidth(rsvg_data.width); d->defaultSize.setHeight(rsvg_data.height); d->viewBox = QRectF(QPointF(0, 0), d->defaultSize); return true; } void DSvgRenderer::render(QPainter *p) { render(p, QString(), QRectF()); } void DSvgRenderer::render(QPainter *p, const QRectF &bounds) { render(p, QString(), bounds); } void DSvgRenderer::render(QPainter *p, const QString &elementId, const QRectF &bounds) { D_D(DSvgRenderer); if (!d->handle) return; p->save(); QImage image(p->device()->width(), p->device()->height(), QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); cairo_surface_t *surface = cairo_image_surface_create_for_data(image.bits(), CAIRO_FORMAT_ARGB32, image.width(), image.height(), image.bytesPerLine()); cairo_t *cairo = cairo_create(surface); cairo_scale(cairo, image.width() / d->viewBox.width(), image.height() / d->viewBox.height()); cairo_translate(cairo, -d->viewBox.x(), -d->viewBox.y()); if (elementId.isEmpty()) rsvg_handle_render_cairo(d->handle, cairo); else rsvg_handle_render_cairo_sub(d->handle, cairo, elementId.toUtf8().constData()); cairo_destroy(cairo); cairo_surface_destroy(surface); if (bounds.isEmpty()) p->drawImage(0, 0, image); else p->drawImage(bounds, image); p->restore(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dsvgrenderer.h000066400000000000000000000042241325435343100202620ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSVGRENDERER_H #define DSVGRENDERER_H #include #include #include #include QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE #ifdef Q_OS_LINUX DWIDGET_BEGIN_NAMESPACE class DSvgRendererPrivate; class DSvgRenderer : public QObject, public DTK_CORE_NAMESPACE::DObject { Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox) public: DSvgRenderer(QObject *parent = Q_NULLPTR); DSvgRenderer(const QString &filename, QObject *parent = Q_NULLPTR); DSvgRenderer(const QByteArray &contents, QObject *parent = Q_NULLPTR); ~DSvgRenderer(); bool isValid() const; QSize defaultSize() const; QRect viewBox() const; QRectF viewBoxF() const; void setViewBox(const QRect &viewbox); void setViewBox(const QRectF &viewbox); QRectF boundsOnElement(const QString &id) const; bool elementExists(const QString &id) const; static QPixmap render(const QString &svgPath, const QSize &sz); public Q_SLOTS: bool load(const QString &filename); bool load(const QByteArray &contents); void render(QPainter *p); void render(QPainter *p, const QRectF &bounds); void render(QPainter *p, const QString &elementId, const QRectF &bounds = QRectF()); private: D_DECLARE_PRIVATE(DSvgRenderer) }; DWIDGET_END_NAMESPACE #else #include DWIDGET_BEGIN_NAMESPACE typedef QSvgRenderer DSvgRenderer; DWIDGET_END_NAMESPACE #endif #endif // DSVGRENDERER_H dtkwidget-2.0.7.2/src/util/dthumbnailprovider.cpp000066400000000000000000000265421325435343100220340ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dthumbnailprovider.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE #define FORMAT ".png" #define THUMBNAIL_PATH \ DCORE_NAMESPACE::DStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/thumbnails" #define THUMBNAIL_FAIL_PATH THUMBNAIL_PATH"/fail" #define THUMBNAIL_LARGE_PATH THUMBNAIL_PATH"/large" #define THUMBNAIL_NORMAL_PATH THUMBNAIL_PATH"/normal" #define THUMBNAIL_SMALL_PATH THUMBNAIL_PATH"/small" inline QByteArray dataToMd5Hex(const QByteArray &data) { return QCryptographicHash::hash(data, QCryptographicHash::Md5).toHex(); } class DThumbnailProviderPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DThumbnailProviderPrivate(DThumbnailProvider *qq); void init(); QString sizeToFilePath(DThumbnailProvider::Size size) const; QString errorString; // MAX qint64 defaultSizeLimit = INT64_MAX; QHash sizeLimitHash; QMimeDatabase mimeDatabase; static QSet hasThumbnailMimeHash; struct ProduceInfo { QFileInfo fileInfo; DThumbnailProvider::Size size; DThumbnailProvider::CallBack callback; }; QQueue produceQueue; QSet> discardedProduceInfos; bool running = true; QWaitCondition waitCondition; QReadWriteLock dataReadWriteLock; D_DECLARE_PUBLIC(DThumbnailProvider) }; QSet DThumbnailProviderPrivate::hasThumbnailMimeHash; DThumbnailProviderPrivate::DThumbnailProviderPrivate(DThumbnailProvider *qq) : DObjectPrivate(qq) { } void DThumbnailProviderPrivate::init() { } QString DThumbnailProviderPrivate::sizeToFilePath(DThumbnailProvider::Size size) const { switch (size) { case DThumbnailProvider::Small: return THUMBNAIL_SMALL_PATH; case DThumbnailProvider::Normal: return THUMBNAIL_NORMAL_PATH; case DThumbnailProvider::Large: return THUMBNAIL_LARGE_PATH; } return QString(); } class DFileThumbnailProviderPrivate : public DThumbnailProvider {}; Q_GLOBAL_STATIC(DFileThumbnailProviderPrivate, ftpGlobal) DThumbnailProvider *DThumbnailProvider::instance() { return ftpGlobal; } bool DThumbnailProvider::hasThumbnail(const QFileInfo &info) const { Q_D(const DThumbnailProvider); if (!info.isReadable() || !info.isFile()) { return false; } qint64 fileSize = info.size(); if (fileSize <= 0) { return false; } const QMimeType &mime = d->mimeDatabase.mimeTypeForFile(info); if (fileSize > sizeLimit(mime)) { return false; } return hasThumbnail(mime); } bool DThumbnailProvider::hasThumbnail(const QMimeType &mimeType) const { const QString &mime = mimeType.name(); if (DThumbnailProviderPrivate::hasThumbnailMimeHash.isEmpty()) { const QList &mimeTypes = QImageReader::supportedMimeTypes(); if (mimeTypes.isEmpty()) { DThumbnailProviderPrivate::hasThumbnailMimeHash.insert(""); return false; } DThumbnailProviderPrivate::hasThumbnailMimeHash.reserve(mimeTypes.size()); for (const QByteArray &t : mimeTypes) { DThumbnailProviderPrivate::hasThumbnailMimeHash.insert(QString::fromLocal8Bit(t)); } } return DThumbnailProviderPrivate::hasThumbnailMimeHash.contains(mime); } QString DThumbnailProvider::thumbnailFilePath(const QFileInfo &info, Size size) const { Q_D(const DThumbnailProvider); const QString &absolutePath = info.absolutePath(); const QString &absoluteFilePath = info.absoluteFilePath(); if (absolutePath == d->sizeToFilePath(Small) || absolutePath == d->sizeToFilePath(Normal) || absolutePath == d->sizeToFilePath(Large) || absolutePath == THUMBNAIL_FAIL_PATH) { return absoluteFilePath; } const QString thumbnailName = dataToMd5Hex(QUrl::fromLocalFile(absoluteFilePath).toString(QUrl::FullyEncoded).toLocal8Bit()) + FORMAT; QString thumbnail = d->sizeToFilePath(size) + QDir::separator() + thumbnailName; if (!QFile::exists(thumbnail)) { return QString(); } QImage image(thumbnail); if (image.text(QT_STRINGIFY(Thumb::MTime)).toInt() != (int)info.lastModified().toTime_t()) { QFile::remove(thumbnail); Q_EMIT thumbnailChanged(absoluteFilePath, QString()); return QString(); } return thumbnail; } QString DThumbnailProvider::createThumbnail(const QFileInfo &info, DThumbnailProvider::Size size) { Q_D(DThumbnailProvider); d->errorString.clear(); const QString &absolutePath = info.absolutePath(); const QString &absoluteFilePath = info.absoluteFilePath(); if (absolutePath == d->sizeToFilePath(Small) || absolutePath == d->sizeToFilePath(Normal) || absolutePath == d->sizeToFilePath(Large) || absolutePath == THUMBNAIL_FAIL_PATH) { return absoluteFilePath; } if (!hasThumbnail(info)) { d->errorString = QStringLiteral("This file has not support thumbnail: ") + absoluteFilePath; //!Warnning: Do not store thumbnails to the fail path return QString(); } const QString fileUrl = QUrl::fromLocalFile(absoluteFilePath).toString(QUrl::FullyEncoded); const QString thumbnailName = dataToMd5Hex(fileUrl.toLocal8Bit()) + FORMAT; // the file is in fail path QString thumbnail = THUMBNAIL_FAIL_PATH + QDir::separator() + thumbnailName; if (QFile::exists(thumbnail)) { QImage image(thumbnail); if (image.text(QT_STRINGIFY(Thumb::MTime)).toInt() != (int)info.lastModified().toTime_t()) { QFile::remove(thumbnail); } else { return QString(); } }// end QScopedPointer image(new QImage(QSize(size, size), QImage::Format_ARGB32_Premultiplied)); QImageReader reader(absoluteFilePath); if (!reader.canRead()) { reader.setFormat(d->mimeDatabase.mimeTypeForFile(info).name().toLocal8Bit()); if (!reader.canRead()) { d->errorString = reader.errorString(); } } if (d->errorString.isEmpty()) { const QSize &imageSize = reader.size(); if (imageSize.isValid()) { if (imageSize.width() >= size || imageSize.height() >= size) { reader.setScaledSize(reader.size().scaled(size, size, Qt::KeepAspectRatio)); } if (!reader.read(image.data())) { d->errorString = reader.errorString(); } } else { d->errorString = "Fail to read image file attribute data:" + info.absoluteFilePath(); } } // successful if (d->errorString.isEmpty()) { thumbnail = d->sizeToFilePath(size) + QDir::separator() + thumbnailName; } else { //fail image.reset(new QImage(1, 1, QImage::Format_Mono)); } image->setText(QT_STRINGIFY(Thumb::URL), fileUrl); image->setText(QT_STRINGIFY(Thumb::MTime), QString::number(info.lastModified().toTime_t())); // create path QFileInfo(thumbnail).absoluteDir().mkpath("."); if (!image->save(thumbnail, Q_NULLPTR, 80)) { d->errorString = QStringLiteral("Can not save image to ") + thumbnail; } if (d->errorString.isEmpty()) { Q_EMIT createThumbnailFinished(absoluteFilePath, thumbnail); Q_EMIT thumbnailChanged(absoluteFilePath, thumbnail); return thumbnail; } // fail Q_EMIT createThumbnailFailed(absoluteFilePath); return QString(); } void DThumbnailProvider::appendToProduceQueue(const QFileInfo &info, DThumbnailProvider::Size size, DThumbnailProvider::CallBack callback) { DThumbnailProviderPrivate::ProduceInfo produceInfo; produceInfo.fileInfo = info; produceInfo.size = size; produceInfo.callback = callback; Q_D(DThumbnailProvider); if (isRunning()) { QWriteLocker locker(&d->dataReadWriteLock); d->produceQueue.append(std::move(produceInfo)); locker.unlock(); d->waitCondition.wakeAll(); } else { d->produceQueue.append(std::move(produceInfo)); start(); } } void DThumbnailProvider::removeInProduceQueue(const QFileInfo &info, DThumbnailProvider::Size size) { Q_D(DThumbnailProvider); if (isRunning()) { QWriteLocker locker(&d->dataReadWriteLock); Q_UNUSED(locker) } d->discardedProduceInfos.insert(qMakePair(info.absoluteFilePath(), size)); } QString DThumbnailProvider::errorString() const { Q_D(const DThumbnailProvider); return d->errorString; } qint64 DThumbnailProvider::defaultSizeLimit() const { Q_D(const DThumbnailProvider); return d->defaultSizeLimit; } void DThumbnailProvider::setDefaultSizeLimit(qint64 size) { Q_D(DThumbnailProvider); d->defaultSizeLimit = size; } qint64 DThumbnailProvider::sizeLimit(const QMimeType &mimeType) const { Q_D(const DThumbnailProvider); return d->sizeLimitHash.value(mimeType, d->defaultSizeLimit); } void DThumbnailProvider::setSizeLimit(const QMimeType &mimeType, qint64 size) { Q_D(DThumbnailProvider); d->sizeLimitHash[mimeType] = size; } DThumbnailProvider::DThumbnailProvider(QObject *parent) : QThread(parent) , DObject(*new DThumbnailProviderPrivate(this)) { d_func()->init(); } DThumbnailProvider::~DThumbnailProvider() { Q_D(DThumbnailProvider); d->running = false; d->waitCondition.wakeAll(); wait(); } void DThumbnailProvider::run() { Q_D(DThumbnailProvider); Q_FOREVER { QWriteLocker locker(&d->dataReadWriteLock); if (d->produceQueue.isEmpty()) { d->waitCondition.wait(&d->dataReadWriteLock); } if (!d->running) { return; } const DThumbnailProviderPrivate::ProduceInfo &task = d->produceQueue.dequeue(); const QPair &tmpKey = qMakePair(task.fileInfo.absoluteFilePath(), task.size); if (d->discardedProduceInfos.contains(tmpKey)) { d->discardedProduceInfos.remove(tmpKey); locker.unlock(); continue; } locker.unlock(); const QString &thumbnail = createThumbnail(task.fileInfo, task.size); if (task.callback) { task.callback(thumbnail); } } } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dthumbnailprovider.h000066400000000000000000000045771325435343100215050ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DFILETHUMBNAILPROVIDER_H #define DFILETHUMBNAILPROVIDER_H #include #include #include "dtkwidget_global.h" #include "dobject.h" #include QT_BEGIN_NAMESPACE class QMimeType; QT_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DThumbnailProviderPrivate; class DThumbnailProvider : public QThread, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: enum Size { Small = 64, Normal = 128, Large = 256, }; static DThumbnailProvider *instance(); bool hasThumbnail(const QFileInfo &info) const; bool hasThumbnail(const QMimeType &mimeType) const; QString thumbnailFilePath(const QFileInfo &info, Size size) const; QString createThumbnail(const QFileInfo &info, Size size); typedef std::function CallBack; void appendToProduceQueue(const QFileInfo &info, Size size, CallBack callback = 0); void removeInProduceQueue(const QFileInfo &info, Size size); QString errorString() const; qint64 defaultSizeLimit() const; void setDefaultSizeLimit(qint64 size); qint64 sizeLimit(const QMimeType &mimeType) const; void setSizeLimit(const QMimeType &mimeType, qint64 size); Q_SIGNALS: void thumbnailChanged(const QString &sourceFilePath, const QString &thumbnailPath) const; void createThumbnailFinished(const QString &sourceFilePath, const QString &thumbnailPath) const; void createThumbnailFailed(const QString &sourceFilePath) const; protected: explicit DThumbnailProvider(QObject *parent = 0); ~DThumbnailProvider(); void run() Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DThumbnailProvider) }; DWIDGET_END_NAMESPACE #endif // DFILETHUMBNAILPROVIDER_H dtkwidget-2.0.7.2/src/util/dtrashmanager.h000066400000000000000000000023461325435343100204130ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTRASHMANAGER_H #define DTRASHMANAGER_H #include #include "dtkwidget_global.h" #include DWIDGET_BEGIN_NAMESPACE class DTrashManagerPrivate; class DTrashManager : public QObject, public DTK_CORE_NAMESPACE::DObject { public: static DTrashManager *instance(); bool trashIsEmpty() const; bool cleanTrash(); bool moveToTrash(const QString &filePath, bool followSymlink = false); protected: DTrashManager(); private: D_DECLARE_PRIVATE(DTrashManager) }; DWIDGET_END_NAMESPACE #endif // DTRASHMANAGER_H dtkwidget-2.0.7.2/src/util/dtrashmanager_linux.cpp000066400000000000000000000147571325435343100221760ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dtrashmanager.h" #include #include #include #include #include #include #include #define TRASH_PATH \ DCORE_NAMESPACE::DStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/Trash" #define TRASH_INFO_PATH TRASH_PATH"/info" #define TRASH_FILES_PATH TRASH_PATH"/files" DWIDGET_BEGIN_NAMESPACE class DTrashManager_ : public DTrashManager {}; Q_GLOBAL_STATIC(DTrashManager_, globalTrashManager) static QString getNotExistsFileName(const QString &fileName, const QString &targetPath) { QByteArray name = fileName.toUtf8(); int index = name.lastIndexOf('.'); QByteArray suffix; if (index >= 0) { suffix = name.mid(index); } if (suffix.size() > 200) { suffix = suffix.left(200); } name.chop(suffix.size()); name = name.left(200 - suffix.size()); while (QFile::exists(targetPath + "/" + name + suffix)) { name = QCryptographicHash::hash(name, QCryptographicHash::Md5).toHex(); } return QString::fromUtf8(name + suffix); } static bool writeTrashInfo(const QString &fileBaseName, const QString &sourceFilePath, const QDateTime &datetime, QString *errorString = NULL) { QFile metadata(TRASH_INFO_PATH"/" + fileBaseName + ".trashinfo"); if (metadata.exists()) { if (errorString) { *errorString = QString("The %1 file is exists").arg(metadata.fileName()); } return false; } if (!metadata.open(QIODevice::WriteOnly)) { if (errorString) { *errorString = metadata.errorString(); } return false; } QByteArray data; data.append("[Trash Info]\n"); data.append("Path=").append(sourceFilePath.toUtf8().toPercentEncoding("/")).append("\n"); data.append("DeletionDate=").append(datetime.toString(Qt::ISODate)).append("\n"); qint64 size = metadata.write(data); metadata.close(); if (size <= 0) { if (errorString) { *errorString = metadata.errorString(); } return false; } return true; } static bool renameFile(const QFileInfo &fileInfo, const QString &target, QString *errorString = NULL) { if (fileInfo.isFile() || fileInfo.isSymLink()) { QFile file(fileInfo.filePath()); if (!file.rename(target)) { if (errorString) { *errorString = file.errorString(); } return false; } return true; } else { QDirIterator iterator(fileInfo.filePath(), QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); while (iterator.hasNext()) { iterator.next(); const QString newFile = iterator.filePath().replace(0, fileInfo.filePath().length(), target); if (!QDir().mkpath(QFileInfo(newFile).path())) { if (errorString) { *errorString = QString("Make the %1 path is failed").arg(QFileInfo(newFile).path()); } return false; } if (!renameFile(iterator.fileInfo(), newFile, errorString)) { return false; } } if (!QDir().rmdir(fileInfo.filePath())) { if (errorString) { *errorString = QString("Cannot remove the %1 dir").arg(fileInfo.filePath()); } return false; } } return true; } class DTrashManagerPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DTrashManagerPrivate(DTrashManager *q_ptr) : DObjectPrivate(q_ptr) {} D_DECLARE_PUBLIC(DTrashManager) }; DTrashManager *DTrashManager::instance() { return globalTrashManager; } bool DTrashManager::trashIsEmpty() const { QDirIterator iterator(TRASH_INFO_PATH, // QStringList() << "*.trashinfo", QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden); return !iterator.hasNext(); } bool DTrashManager::cleanTrash() { QDirIterator iterator_info(TRASH_INFO_PATH, // QStringList() << "*.trashinfo", QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden); bool ok = true; while (iterator_info.hasNext()) { if (!QFile::remove(iterator_info.next())) { ok = false; } } QDirIterator iterator_files(TRASH_FILES_PATH, QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden, QDirIterator::Subdirectories); while (iterator_files.hasNext()) { if (!QFile::remove(iterator_files.next())) { ok = false; } } return ok; } bool DTrashManager::moveToTrash(const QString &filePath, bool followSymlink) { QFileInfo fileInfo(filePath); if (!fileInfo.exists() && (followSymlink || !fileInfo.isSymLink())) { return false; } QDir trashDir(TRASH_FILES_PATH); QStorageInfo storageInfo(fileInfo.filePath()); QStorageInfo trashStorageInfo(trashDir); if (storageInfo != trashStorageInfo) { return false; } if (!trashDir.mkpath(TRASH_INFO_PATH)) { return false; } if (!trashDir.mkpath(TRASH_FILES_PATH)) { return false; } if (followSymlink && fileInfo.isSymLink()) { fileInfo.setFile(fileInfo.symLinkTarget()); } const QString &fileName = getNotExistsFileName(fileInfo.fileName(), TRASH_FILES_PATH); if (!writeTrashInfo(fileName, fileInfo.filePath(), QDateTime::currentDateTime())) { return false; } const QString &newFilePath = TRASH_FILES_PATH"/" + fileName; return renameFile(fileInfo, newFilePath); } DTrashManager::DTrashManager() : QObject() , DObject(*new DTrashManagerPrivate(this)) { } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dtrashmanager_win.cpp000066400000000000000000000071761325435343100216310ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dtrashmanager.h" #include #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE class DTrashManager_ : public DTrashManager {}; Q_GLOBAL_STATIC(DTrashManager_, globalTrashManager) static QString getNotExistsFileName(const QString &fileName, const QString &targetPath) { QByteArray name = fileName.toUtf8(); int index = name.lastIndexOf('.'); QByteArray suffix; if (index >= 0) { suffix = name.mid(index); } if (suffix.size() > 200) { suffix = suffix.left(200); } name.chop(suffix.size()); name = name.left(200 - suffix.size()); while (QFile::exists(targetPath + "/" + name + suffix)) { name = QCryptographicHash::hash(name, QCryptographicHash::Md5).toHex(); } return QString::fromUtf8(name + suffix); } static bool renameFile(const QFileInfo &fileInfo, const QString &target, QString *errorString = NULL) { if (fileInfo.isFile() || fileInfo.isSymLink()) { QFile file(fileInfo.filePath()); if (!file.rename(target)) { if (errorString) { *errorString = file.errorString(); } return false; } return true; } else { QDirIterator iterator(fileInfo.filePath(), QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); while (iterator.hasNext()) { iterator.next(); const QString newFile = iterator.filePath().replace(0, fileInfo.filePath().length(), target); if (!QDir().mkpath(QFileInfo(newFile).path())) { if (errorString) { *errorString = QString("Make the %1 path is failed").arg(QFileInfo(newFile).path()); } return false; } if (!renameFile(iterator.fileInfo(), newFile, errorString)) { return false; } } if (!QDir().rmdir(fileInfo.filePath())) { if (errorString) { *errorString = QString("Cannot remove the %1 dir").arg(fileInfo.filePath()); } return false; } } return true; } class DTrashManagerPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DTrashManagerPrivate(DTrashManager *q_ptr) : DObjectPrivate(q_ptr) {} D_DECLARE_PUBLIC(DTrashManager) }; DTrashManager *DTrashManager::instance() { return globalTrashManager; } bool DTrashManager::trashIsEmpty() const { return false; } bool DTrashManager::cleanTrash() { return false; } bool DTrashManager::moveToTrash(const QString &filePath, bool followSymlink) { return false; } DTrashManager::DTrashManager() : QObject() , DObject(*new DTrashManagerPrivate(this)) { } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dwidgetutil.cpp000066400000000000000000000046601325435343100204540ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dwidgetutil.h" #include #include #include #include #include QT_BEGIN_NAMESPACE //extern Q_WIDGETS_EXPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0); extern Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); QT_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE QImage dropShadow(const QPixmap &px, qreal radius, const QColor &color) { if (px.isNull()) { return QImage(); } QSize size = px.size(); QImage tmp(size + QSize(radius * 2, radius * 2), QImage::Format_ARGB32_Premultiplied); tmp.fill(0); QPainter tmpPainter(&tmp); tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); tmpPainter.drawPixmap(QPoint(radius, radius), px); tmpPainter.end(); // blur the alpha channel QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); blurred.fill(0); QPainter blurPainter(&blurred); qt_blurImage(&blurPainter, tmp, radius, false, true); blurPainter.end(); if (color == QColor(Qt::black)) { return blurred; } tmp = blurred; // blacken the image... tmpPainter.begin(&tmp); tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); tmpPainter.fillRect(tmp.rect(), color); tmpPainter.end(); return tmp; } void moveToCenter(QWidget *w) { Q_ASSERT(w != nullptr); QDesktopWidget *dw = QApplication::desktop(); QRect parentRect = dw->availableGeometry(dw->primaryScreen()); if (w->parentWidget()) { parentRect = w->parentWidget()->geometry(); } w->move(parentRect.center() - w->rect().center()); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dwidgetutil.h000066400000000000000000000026271325435343100201220ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DUTILITY_H #define DUTILITY_H #include "dtkwidget_global.h" #include #include #include DWIDGET_BEGIN_NAMESPACE QImage dropShadow(const QPixmap &px, qreal radius, const QColor &color = Qt::black); QStringList wordWrapText(const QString &text, int width, QTextOption::WrapMode wrapMode, int *lineCount = 0); QStringList elideText(const QString &text, const QSize &size, const QFontMetrics &fontMetrics, QTextOption::WrapMode wordWrap, Qt::TextElideMode mode, int flags = 0); void moveToCenter(QWidget *w); DWIDGET_END_NAMESPACE #endif // DUTILITY_H dtkwidget-2.0.7.2/src/util/dwindowmanagerhelper.cpp000066400000000000000000000225651325435343100223410ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dwindowmanagerhelper.h" #include "dforeignwindow.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE #define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name #define MWM_FUNC_ALL (1L << 0) #define MWM_DECOR_ALL (1L << 0) // functions DEFINE_CONST_CHAR(hasBlurWindow); DEFINE_CONST_CHAR(hasComposite); DEFINE_CONST_CHAR(connectWindowManagerChangedSignal); DEFINE_CONST_CHAR(connectHasBlurWindowChanged); DEFINE_CONST_CHAR(connectHasCompositeChanged); DEFINE_CONST_CHAR(getCurrentWorkspaceWindows); DEFINE_CONST_CHAR(connectWindowListChanged); DEFINE_CONST_CHAR(setMWMFunctions); DEFINE_CONST_CHAR(getMWMFunctions); DEFINE_CONST_CHAR(setMWMDecorations); DEFINE_CONST_CHAR(getMWMDecorations); DEFINE_CONST_CHAR(connectWindowMotifWMHintsChanged); DEFINE_CONST_CHAR(popupSystemWindowMenu); static bool connectWindowManagerChangedSignal(QObject *object, std::function slot) { QFunctionPointer connectWindowManagerChangedSignal = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) connectWindowManagerChangedSignal = qApp->platformFunction(_connectWindowManagerChangedSignal); #endif return connectWindowManagerChangedSignal && reinterpret_cast)>(connectWindowManagerChangedSignal)(object, slot); } static bool connectHasBlurWindowChanged(QObject *object, std::function slot) { QFunctionPointer connectHasBlurWindowChanged = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) connectHasBlurWindowChanged = qApp->platformFunction(_connectHasBlurWindowChanged); #endif return connectHasBlurWindowChanged && reinterpret_cast)>(connectHasBlurWindowChanged)(object, slot); } static bool connectHasCompositeChanged(QObject *object, std::function slot) { QFunctionPointer connectHasCompositeChanged = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) connectHasCompositeChanged = qApp->platformFunction(_connectHasCompositeChanged); #endif return connectHasCompositeChanged && reinterpret_cast)>(connectHasCompositeChanged)(object, slot); } static bool connectWindowListChanged(QObject *object, std::function slot) { QFunctionPointer connectWindowListChanged = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) connectWindowListChanged = qApp->platformFunction(_connectWindowListChanged); #endif return connectWindowListChanged && reinterpret_cast)>(connectWindowListChanged)(object, slot); } static bool connectWindowMotifWMHintsChanged(QObject *object, std::function slot) { QFunctionPointer connectWindowMotifWMHintsChanged = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) connectWindowMotifWMHintsChanged = qApp->platformFunction(_connectWindowMotifWMHintsChanged); #endif return connectWindowMotifWMHintsChanged && reinterpret_cast)>(connectWindowMotifWMHintsChanged)(object, slot); } class DWindowManagerHelperPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DWindowManagerHelperPrivate(DWindowManagerHelper *qq) : DObjectPrivate(qq) {} mutable QList windowList; }; class DWindowManagerHelper_ : public DWindowManagerHelper {}; Q_GLOBAL_STATIC(DWindowManagerHelper_, wmhGlobal) DWindowManagerHelper::~DWindowManagerHelper() { D_DC(DWindowManagerHelper); for (QWindow *w : d->windowList) { w->deleteLater(); } } DWindowManagerHelper *DWindowManagerHelper::instance() { return wmhGlobal; } void DWindowManagerHelper::setMotifFunctions(const QWindow *window, MotifFunctions hints) { QFunctionPointer setMWMFunctions = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) setMWMFunctions = qApp->platformFunction(_setMWMFunctions); #endif if (setMWMFunctions && window->handle()) { if (hints == FUNC_ALL) hints = (MotifFunction)MWM_FUNC_ALL; reinterpret_cast(setMWMFunctions)(window->handle()->winId(), (quint32)hints); } } DWindowManagerHelper::MotifFunctions DWindowManagerHelper::setMotifFunctions(const QWindow *window, MotifFunctions hints, bool on) { MotifFunctions old_hints = getMotifFunctions(window); if (on) hints |= old_hints; else hints = old_hints & ~hints; setMotifFunctions(window, hints); return hints; } DWindowManagerHelper::MotifFunctions DWindowManagerHelper::getMotifFunctions(const QWindow *window) { QFunctionPointer getMWMFunctions = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) getMWMFunctions = qApp->platformFunction(_getMWMFunctions); #endif if (getMWMFunctions && window->handle()) { quint32 hints = reinterpret_cast(getMWMFunctions)(window->handle()->winId()); if (!(hints & MWM_FUNC_ALL)) return (MotifFunctions)hints; } return FUNC_ALL; } void DWindowManagerHelper::setMotifDecorations(const QWindow *window, MotifDecorations hints) { QFunctionPointer setMWMDecorations = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) setMWMDecorations = qApp->platformFunction(_setMWMDecorations); #endif if (setMWMDecorations && window->handle()) { if (hints == DECOR_ALL) hints = (MotifDecoration)MWM_DECOR_ALL; reinterpret_cast(setMWMDecorations)(window->handle()->winId(), (quint32)hints); } } DWindowManagerHelper::MotifDecorations DWindowManagerHelper::setMotifDecorations(const QWindow *window, MotifDecorations hints, bool on) { MotifDecorations old_hints = getMotifDecorations(window); if (on) hints |= old_hints; else hints = old_hints & ~hints; setMotifDecorations(window, hints); return hints; } DWindowManagerHelper::MotifDecorations DWindowManagerHelper::getMotifDecorations(const QWindow *window) { QFunctionPointer getMWMDecorations = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) getMWMDecorations = qApp->platformFunction(_getMWMDecorations); #endif if (getMWMDecorations && window->handle()) { quint32 hints = reinterpret_cast(getMWMDecorations)(window->handle()->winId()); if (!(hints & MWM_DECOR_ALL)) return (MotifDecorations)hints; } return DECOR_ALL; } void DWindowManagerHelper::popupSystemWindowMenu(const QWindow *window) { QFunctionPointer popupSystemWindowMenu = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) popupSystemWindowMenu = qApp->platformFunction(_popupSystemWindowMenu); #endif if (popupSystemWindowMenu && window->handle()) { reinterpret_cast(popupSystemWindowMenu)(window->handle()->winId()); } } bool DWindowManagerHelper::hasBlurWindow() const { QFunctionPointer wmHasBlurWindow = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) wmHasBlurWindow = qApp->platformFunction(_hasBlurWindow); #endif return wmHasBlurWindow && reinterpret_cast(wmHasBlurWindow)(); } bool DWindowManagerHelper::hasComposite() const { QFunctionPointer hasComposite = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) hasComposite = qApp->platformFunction(_hasComposite); #endif return hasComposite && reinterpret_cast(hasComposite)(); } QList DWindowManagerHelper::currentWorkspaceWindows() const { D_DC(DWindowManagerHelper); for (QWindow *w : d->windowList) { w->deleteLater(); } d->windowList.clear(); QFunctionPointer wmClientList = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) wmClientList = qApp->platformFunction(_getCurrentWorkspaceWindows); #endif if (wmClientList) { for (WId wid : reinterpret_cast(*)()>(wmClientList)()) { if (DForeignWindow *w = DForeignWindow::fromWinId(wid)) { d->windowList << w; } } } return d->windowList; } DWindowManagerHelper::DWindowManagerHelper(QObject *parent) : QObject(parent) , DObject(*new DWindowManagerHelperPrivate(this)) { connectWindowManagerChangedSignal(this, [this] { Q_EMIT windowManagerChanged(); }); connectHasBlurWindowChanged(this, [this] { Q_EMIT hasBlurWindowChanged(); }); connectHasCompositeChanged(this, [this] { Q_EMIT hasCompositeChanged(); }); connectWindowListChanged(this, [this] { Q_EMIT windowListChanged(); }); connectWindowMotifWMHintsChanged(this, [this] (quint32 winId) { Q_EMIT windowMotifWMHintsChanged(winId); }); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/util/dwindowmanagerhelper.h000066400000000000000000000063201325435343100217750ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWINDOWMANAGERHELPER_H #define DWINDOWMANAGERHELPER_H #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DForeignWindow; class DWindowManagerHelperPrivate; class DWindowManagerHelper : public QObject, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(bool hasBlurWindow READ hasBlurWindow NOTIFY hasBlurWindowChanged) Q_PROPERTY(bool hasComposite READ hasComposite NOTIFY hasCompositeChanged) public: enum MotifFunction { FUNC_RESIZE = (1L << 1), FUNC_MOVE = (1L << 2), FUNC_MINIMIZE = (1L << 3), FUNC_MAXIMIZE = (1L << 4), FUNC_CLOSE = (1L << 5), FUNC_ALL = FUNC_RESIZE | FUNC_MOVE | FUNC_MINIMIZE | FUNC_MAXIMIZE | FUNC_CLOSE }; Q_DECLARE_FLAGS(MotifFunctions, MotifFunction) enum MotifDecoration { DECOR_BORDER = (1L << 1), DECOR_RESIZEH = (1L << 2), DECOR_TITLE = (1L << 3), DECOR_MENU = (1L << 4), DECOR_MINIMIZE = (1L << 5), DECOR_MAXIMIZE = (1L << 6), DECOR_ALL = DECOR_BORDER | DECOR_RESIZEH | DECOR_TITLE | DECOR_MENU | DECOR_MINIMIZE | DECOR_MAXIMIZE }; Q_DECLARE_FLAGS(MotifDecorations, MotifDecoration) ~DWindowManagerHelper(); static DWindowManagerHelper *instance(); static void setMotifFunctions(const QWindow *window, MotifFunctions hints); static MotifFunctions setMotifFunctions(const QWindow *window, MotifFunctions hints, bool on); static MotifFunctions getMotifFunctions(const QWindow *window); static void setMotifDecorations(const QWindow *window, MotifDecorations hints); static MotifDecorations setMotifDecorations(const QWindow *window, MotifDecorations hints, bool on); static MotifDecorations getMotifDecorations(const QWindow *window); static void popupSystemWindowMenu(const QWindow *window); bool hasBlurWindow() const; bool hasComposite() const; QList currentWorkspaceWindows() const; Q_SIGNALS: void windowManagerChanged(); void hasBlurWindowChanged(); void hasCompositeChanged(); void windowListChanged(); void windowMotifWMHintsChanged(quint32 winId); protected: explicit DWindowManagerHelper(QObject *parent = 0); private: D_DECLARE_PRIVATE(DWindowManagerHelper) }; DWIDGET_END_NAMESPACE Q_DECLARE_OPERATORS_FOR_FLAGS(DTK_WIDGET_NAMESPACE::DWindowManagerHelper::MotifFunctions) Q_DECLARE_OPERATORS_FOR_FLAGS(DTK_WIDGET_NAMESPACE::DWindowManagerHelper::MotifDecorations) #endif // DWINDOWMANAGERHELPER_H dtkwidget-2.0.7.2/src/util/private/000077500000000000000000000000001325435343100170675ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/util/private/dregionmonitor_p.h000066400000000000000000000032351325435343100226210ustar00rootroot00000000000000#ifndef DREGIONMONITOR_P_H #define DREGIONMONITOR_P_H #include "dtkwidget_global.h" #include "dobject_p.h" #include "../dregionmonitor.h" #include #include #ifdef DFRAMEWORKDBUS_API_XEVENTMONITOR #include #else #include #endif DCORE_USE_NAMESPACE DWIDGET_BEGIN_NAMESPACE #ifdef DFRAMEWORKDBUS_API_XEVENTMONITOR using XEventMonitor = ::com::deepin::api::XEventMonitor; #else using XMousAreaInter = ::com::deepin::api::XMouseArea; #endif class DRegionMonitorPrivate : public DObjectPrivate { D_DECLARE_PUBLIC(DRegionMonitor) public: DRegionMonitorPrivate(DRegionMonitor *q); ~DRegionMonitorPrivate(); enum Flag{ Motion = 1 << 0, Button = 1 << 1, Key = 1 << 2 }; bool registered() const { return !registerKey.isEmpty(); } void init(); void registerMonitorRegion(); void unregisterMonitorRegion(); void _q_ButtonPress(const int flag, const int x, const int y, const QString &key); void _q_ButtonRelease(const int flag, const int x, const int y, const QString &key); void _q_CursorMove(const int x, const int y, const QString &key); void _q_KeyPress(const QString &keyname, const int x, const int y, const QString &key); void _q_KeyRelease(const QString &keyname, const int x, const int y, const QString &key); const QPoint deviceScaledCoordinate(const QPoint &p, const double ratio) const; #ifdef DFRAMEWORKDBUS_API_XEVENTMONITOR XEventMonitor *eventInter; #else XMousAreaInter *eventInter; #endif QRegion watchedRegion; QString registerKey; }; DWIDGET_END_NAMESPACE #endif // DREGIONMONITOR_P_H dtkwidget-2.0.7.2/src/util/util.pri000066400000000000000000000026131325435343100171100ustar00rootroot00000000000000INCLUDEPATH += $$PWD HEADERS += \ $$PWD/dfileiconprovider.h \ $$PWD/dthumbnailprovider.h \ $$PWD/dwindowmanagerhelper.h \ $$PWD/dwidgetutil.h \ $$PWD/ddesktopservices.h \ $$PWD/dtrashmanager.h \ $$PWD/dsvgrenderer.h \ $$PWD/dhidpihelper.h SOURCES += \ $$PWD/dfileiconprovider.cpp \ $$PWD/dthumbnailprovider.cpp \ $$PWD/dwindowmanagerhelper.cpp \ $$PWD/dwidgetutil.cpp \ $$PWD/dhidpihelper.cpp linux* { CONFIG += link_pkgconfig PKGCONFIG += gsettings-qt librsvg-2.0 dframeworkdbus HEADERS += \ $$PWD/dregionmonitor.h \ $$PWD/private/dregionmonitor_p.h SOURCES += \ $$PWD/ddesktopservices_linux.cpp \ $$PWD/dtrashmanager_linux.cpp \ $$PWD/dsvgrenderer.cpp\ $$PWD/dregionmonitor.cpp } win32* | macx* { SOURCES += \ $$PWD/ddesktopservices_win.cpp \ $$PWD/dtrashmanager_win.cpp } packagesExist(gtk+-2.0) { DEFINES += USE_GTK_PLUS_2_0 INCLUDE_PATH = $$system(pkg-config --cflags-only-I gtk+-2.0) INCLUDEPATH += $$replace(INCLUDE_PATH, -I, ) } includes.files += $$PWD/*.h \ $$PWD/DWidgetUtil \ $$PWD/DDesktopServices \ $$PWD/DTrashManager \ $$PWD/DThumbnailProvider \ $$PWD/DFileIconProvider \ $$PWD/DWindowManagerHelper \ $$PWD/DHiDPIHelper \ $$PWD/DSvgRenderer DISTFILES += \ $$PWD/desktop.pri \ $$PWD/DHiDPIHelper dtkwidget-2.0.7.2/src/widgets/000077500000000000000000000000001325435343100161065ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/DAboutDialog000066400000000000000000000000321325435343100203220ustar00rootroot00000000000000#include "daboutdialog.h" dtkwidget-2.0.7.2/src/widgets/DAction000066400000000000000000000000231325435343100173450ustar00rootroot00000000000000#include dtkwidget-2.0.7.2/src/widgets/DAnchors000066400000000000000000000000261325435343100175300ustar00rootroot00000000000000#include "danchors.h" dtkwidget-2.0.7.2/src/widgets/DAnchorsBase000066400000000000000000000000261325435343100203230ustar00rootroot00000000000000#include "danchors.h" dtkwidget-2.0.7.2/src/widgets/DApplication000066400000000000000000000000321325435343100203730ustar00rootroot00000000000000#include "dapplication.h" dtkwidget-2.0.7.2/src/widgets/DArrowButton000066400000000000000000000000321325435343100204160ustar00rootroot00000000000000#include "darrowbutton.h" dtkwidget-2.0.7.2/src/widgets/DArrowLineExpand000066400000000000000000000000361325435343100211760ustar00rootroot00000000000000#include "darrowlineexpand.h" dtkwidget-2.0.7.2/src/widgets/DBlurEffectWidget000066400000000000000000000000371325435343100213220ustar00rootroot00000000000000#include "dblureffectwidget.h" dtkwidget-2.0.7.2/src/widgets/DClipEffectWidget000066400000000000000000000000371325435343100213050ustar00rootroot00000000000000#include "dclipeffectwidget.h" dtkwidget-2.0.7.2/src/widgets/DCrumbEdit000066400000000000000000000000301325435343100200040ustar00rootroot00000000000000#include "dcrumbedit.h" dtkwidget-2.0.7.2/src/widgets/DExpandGroup000066400000000000000000000000321325435343100203640ustar00rootroot00000000000000#include "dexpandgroup.h" dtkwidget-2.0.7.2/src/widgets/DFileDialog000066400000000000000000000000311325435343100201260ustar00rootroot00000000000000#include "dfiledialog.h" dtkwidget-2.0.7.2/src/widgets/DForeignWindow000066400000000000000000000000341325435343100207130ustar00rootroot00000000000000#include "dforeignwindow.h" dtkwidget-2.0.7.2/src/widgets/DGraphicsClipEffect000066400000000000000000000000411325435343100216150ustar00rootroot00000000000000#include "dgraphicsclipeffect.h" dtkwidget-2.0.7.2/src/widgets/DGraphicsDropShadowEffect000066400000000000000000000000411325435343100230000ustar00rootroot00000000000000#include "dgraphicsgloweffect.h" dtkwidget-2.0.7.2/src/widgets/DMainWindow000066400000000000000000000000311325435343100202030ustar00rootroot00000000000000#include "dmainwindow.h" dtkwidget-2.0.7.2/src/widgets/DMenu000066400000000000000000000000211325435343100170320ustar00rootroot00000000000000#include dtkwidget-2.0.7.2/src/widgets/DPageIndicator000066400000000000000000000000341325435343100206430ustar00rootroot00000000000000#include "dpageindicator.h" dtkwidget-2.0.7.2/src/widgets/DPlatformWindowHandle000066400000000000000000000000431325435343100222220ustar00rootroot00000000000000#include "dplatformwindowhandle.h" dtkwidget-2.0.7.2/src/widgets/DSearchEdit000066400000000000000000000000311325435343100201420ustar00rootroot00000000000000#include "dsearchedit.h" dtkwidget-2.0.7.2/src/widgets/DSettingsDialog000066400000000000000000000000351325435343100210530ustar00rootroot00000000000000#include "dsettingsdialog.h" dtkwidget-2.0.7.2/src/widgets/DSettingsWidgetFactory000066400000000000000000000000441325435343100224270ustar00rootroot00000000000000#include "dsettingswidgetfactory.h" dtkwidget-2.0.7.2/src/widgets/DSimpleListItem000066400000000000000000000000351325435343100210370ustar00rootroot00000000000000#include "dsimplelistitem.h" dtkwidget-2.0.7.2/src/widgets/DSimpleListView000066400000000000000000000000351325435343100210530ustar00rootroot00000000000000#include "dsimplelistview.h" dtkwidget-2.0.7.2/src/widgets/DSpinner000066400000000000000000000000261325435343100175510ustar00rootroot00000000000000#include "dspinner.h" dtkwidget-2.0.7.2/src/widgets/DStyleOption000066400000000000000000000000321325435343100204210ustar00rootroot00000000000000#include "dstyleoption.h" dtkwidget-2.0.7.2/src/widgets/DSuggestButton000066400000000000000000000000341325435343100207470ustar00rootroot00000000000000#include "dsuggestbutton.h" dtkwidget-2.0.7.2/src/widgets/DTabBar000066400000000000000000000000251325435343100172650ustar00rootroot00000000000000#include "dtabbar.h" dtkwidget-2.0.7.2/src/widgets/DThemeManager000066400000000000000000000000331325435343100204660ustar00rootroot00000000000000#include "dthememanager.h" dtkwidget-2.0.7.2/src/widgets/DTitlebar000066400000000000000000000000271325435343100177020ustar00rootroot00000000000000#include "dtitlebar.h" dtkwidget-2.0.7.2/src/widgets/DToast000066400000000000000000000000241325435343100172230ustar00rootroot00000000000000#include dtkwidget-2.0.7.2/src/widgets/DVideoWidget000066400000000000000000000000321325435343100203420ustar00rootroot00000000000000#include "dvideowidget.h" dtkwidget-2.0.7.2/src/widgets/DWaterProgress000066400000000000000000000000341325435343100207410ustar00rootroot00000000000000#include "dwaterprogress.h" dtkwidget-2.0.7.2/src/widgets/DWindow000066400000000000000000000000251325435343100174010ustar00rootroot00000000000000#include "dwindow.h" dtkwidget-2.0.7.2/src/widgets/anchors.cpp000066400000000000000000000705711325435343100202610ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "anchors.h" #include "denhancedwidget.h" DWIDGET_BEGIN_NAMESPACE class AnchorsBasePrivate : public QSharedData { AnchorsBasePrivate(AnchorsBase *qq): q_ptr(qq) {} ~AnchorsBasePrivate() { delete top; delete bottom; delete left; delete right; delete horizontalCenter; delete verticalCenter; } static void setWidgetAnchorsBase(const QWidget *w, AnchorsBase *b) { if (w) { AnchorsBase *bb = widgetMap.value(w, NULL); if (bb) { bb->deleteLater(); } widgetMap[w] = b; } } static AnchorsBase *getWidgetAnchorsBase(const QWidget *w) { return widgetMap.value(w, NULL); } static void removeWidgetAnchorsBase(const QWidget *w, const AnchorsBase *b) { if (w && b && widgetMap.value(w, NULL) == b) { widgetMap.remove(w); } } const AnchorInfo *getInfoByPoint(const Qt::AnchorPoint &p) const { switch (p) { case Qt::AnchorTop: return top; case Qt::AnchorBottom: return bottom; case Qt::AnchorLeft: return left; case Qt::AnchorRight: return right; case Qt::AnchorHorizontalCenter: return horizontalCenter; case Qt::AnchorVerticalCenter: return verticalCenter; default: return NULL; } } bool checkInfo(const AnchorInfo *info1, const AnchorInfo *info2) const { const Qt::AnchorPoint &p = info2->type; switch (info1->type) { case Qt::AnchorTop://Deliberate case Qt::AnchorBottom://Deliberate case Qt::AnchorVerticalCenter: return (p == Qt::AnchorTop || p == Qt::AnchorBottom || p == Qt::AnchorVerticalCenter); case Qt::AnchorLeft://Deliberate case Qt::AnchorRight://Deliberate case Qt::AnchorHorizontalCenter: return (p == Qt::AnchorLeft || p == Qt::AnchorRight || p == Qt::AnchorHorizontalCenter); default: return false; } } bool isBindable(const AnchorInfo *info) const { if (fill->target() || centerIn->target()) { return false; } Q_Q(const AnchorsBase); bool tmp1 = ((int)q->isBinding(top) + (int)q->isBinding(verticalCenter) + (int)q->isBinding(bottom)) < 2; bool tmp2 = ((int)q->isBinding(left) + (int)q->isBinding(horizontalCenter) + (int)q->isBinding(right)) < 2; switch (info->type) { case Qt::AnchorTop://Deliberate case Qt::AnchorBottom://Deliberate case Qt::AnchorHorizontalCenter: return tmp1; case Qt::AnchorLeft://Deliberate case Qt::AnchorRight://Deliberate case Qt::AnchorVerticalCenter: return tmp2; default: return false; } } qreal getValueByInfo(const AnchorInfo *info) { ARect rect = info->base->target()->geometry(); switch (info->type) { case Qt::AnchorTop: return rect.top(); case Qt::AnchorBottom: return rect.bottom() + 1; case Qt::AnchorHorizontalCenter: return rect.horizontalCenter(); case Qt::AnchorLeft: return rect.left(); case Qt::AnchorRight: return rect.right() + 1; case Qt::AnchorVerticalCenter: return rect.verticalCenter(); default: return 0; } } void setValueByInfo(qreal value, const AnchorInfo *info) { if (!info) { return; } switch (info->type) { case Qt::AnchorTop: info->base->setTop(value, Qt::AnchorTop); break; case Qt::AnchorBottom: info->base->setBottom(value - 1, Qt::AnchorTop); break; case Qt::AnchorHorizontalCenter: info->base->setHorizontalCenter(value, Qt::AnchorLeft); break; case Qt::AnchorLeft: info->base->setLeft(value, Qt::AnchorRight); break; case Qt::AnchorRight: info->base->setRight(value - 1, Qt::AnchorLeft); break; case Qt::AnchorVerticalCenter: info->base->setVerticalCenter(value, Qt::AnchorLeft); break; default: break; } } qreal getTargetValueByInfo(const AnchorInfo *info) { if (!info->targetInfo) { return getValueByInfo(info); } qreal value = getValueByInfo(info->targetInfo); bool isParent = info->base->target()->parentWidget() == info->targetInfo->base->target(); int topValue = isParent ? -info->targetInfo->base->target()->geometry().top() : 0; int leftValue = isParent ? -info->targetInfo->base->target()->geometry().left() : 0; switch (info->type) { case Qt::AnchorTop: { int offset = topMargin == 0 ? margins : topMargin; return value + offset + topValue; } case Qt::AnchorBottom: { int offset = bottomMargin == 0 ? margins : bottomMargin; return value - offset + topValue - 1; } case Qt::AnchorHorizontalCenter: { int offset = horizontalCenterOffset; return value + offset + leftValue; } case Qt::AnchorLeft: { int offset = leftMargin == 0 ? margins : leftMargin; return value + offset + leftValue; } case Qt::AnchorRight: { int offset = rightMargin == 0 ? margins : rightMargin; return value - offset + leftValue - 1; } case Qt::AnchorVerticalCenter: { int offset = verticalCenterOffset; return value + offset + topValue; } default: return 0; } } const ARect getWidgetRect(const QWidget *w) const { if (!w) { return ARect(); } if (extendWidget && extendWidget->target()->parentWidget() == w) { return w->rect(); } return w->geometry(); } int horizontalAnchorCount() const { Q_Q(const AnchorsBase); int count = 0; if(q->isBinding(left)) ++count; if(q->isBinding(horizontalCenter)) ++count; if(q->isBinding(right)) ++count; return count; } int verticalAnchorCount() const { Q_Q(const AnchorsBase); int count = 0; if(q->isBinding(top)) ++count; if(q->isBinding(verticalCenter)) ++count; if(q->isBinding(bottom)) ++count; return count; } AnchorsBase *q_ptr; QPointer extendWidget; AnchorInfo *top = new AnchorInfo(q_ptr, Qt::AnchorTop); AnchorInfo *bottom = new AnchorInfo(q_ptr, Qt::AnchorBottom); AnchorInfo *left = new AnchorInfo(q_ptr, Qt::AnchorLeft); AnchorInfo *right = new AnchorInfo(q_ptr, Qt::AnchorRight); AnchorInfo *horizontalCenter = new AnchorInfo(q_ptr, Qt::AnchorHorizontalCenter); AnchorInfo *verticalCenter = new AnchorInfo(q_ptr, Qt::AnchorVerticalCenter); DEnhancedWidget *fill = new DEnhancedWidget(NULL, q_ptr); DEnhancedWidget *centerIn = new DEnhancedWidget(NULL, q_ptr); int margins = 0; int topMargin = 0; int bottomMargin = 0; int leftMargin = 0; int rightMargin = 0; int horizontalCenterOffset = 0; int verticalCenterOffset = 0; bool alignWhenCentered = false; AnchorsBase::AnchorError errorCode = AnchorsBase::NoError; QString errorString; static QMap widgetMap; Q_DECLARE_PUBLIC(AnchorsBase) }; QMap AnchorsBasePrivate::widgetMap; AnchorsBase::AnchorsBase(QWidget *w): QObject(w) { init(w); } AnchorsBase::~AnchorsBase() { AnchorsBasePrivate::removeWidgetAnchorsBase(target(), this); } QWidget *AnchorsBase::target() const { Q_D(const AnchorsBase); if (!d->extendWidget) return 0; return d->extendWidget->target(); } DEnhancedWidget *AnchorsBase::enhancedWidget() const { Q_D(const AnchorsBase); return d->extendWidget; } bool AnchorsBase::enabled() const { Q_D(const AnchorsBase); if (!d->extendWidget) return false; return d->extendWidget->enabled(); } const AnchorsBase *AnchorsBase::anchors() const { return this; } const AnchorInfo *AnchorsBase::top() const { Q_D(const AnchorsBase); return d->top; } const AnchorInfo *AnchorsBase::bottom() const { Q_D(const AnchorsBase); return d->bottom; } const AnchorInfo *AnchorsBase::left() const { Q_D(const AnchorsBase); return d->left; } const AnchorInfo *AnchorsBase::right() const { Q_D(const AnchorsBase); return d->right; } const AnchorInfo *AnchorsBase::horizontalCenter() const { Q_D(const AnchorsBase); return d->horizontalCenter; } const AnchorInfo *AnchorsBase::verticalCenter() const { Q_D(const AnchorsBase); return d->verticalCenter; } QWidget *AnchorsBase::fill() const { Q_D(const AnchorsBase); if (d->fill) { return d->fill->target(); } return NULL; } QWidget *AnchorsBase::centerIn() const { Q_D(const AnchorsBase); if (d->centerIn) { return d->centerIn->target(); } return NULL; } int AnchorsBase::margins() const { Q_D(const AnchorsBase); return d->margins; } int AnchorsBase::topMargin() const { Q_D(const AnchorsBase); return d->topMargin; } int AnchorsBase::bottomMargin() const { Q_D(const AnchorsBase); return d->bottomMargin; } int AnchorsBase::leftMargin() const { Q_D(const AnchorsBase); return d->leftMargin; } int AnchorsBase::rightMargin() const { Q_D(const AnchorsBase); return d->rightMargin; } int AnchorsBase::horizontalCenterOffset() const { Q_D(const AnchorsBase); return d->horizontalCenterOffset; } int AnchorsBase::verticalCenterOffset() const { Q_D(const AnchorsBase); return d->verticalCenterOffset; } int AnchorsBase::alignWhenCentered() const { Q_D(const AnchorsBase); return d->alignWhenCentered; } AnchorsBase::AnchorError AnchorsBase::errorCode() const { Q_D(const AnchorsBase); return d->errorCode; } QString AnchorsBase::errorString() const { Q_D(const AnchorsBase); return d->errorString; } bool AnchorsBase::isBinding(const AnchorInfo *info) const { return info->targetInfo; } bool AnchorsBase::setAnchor(QWidget *w, const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point) { if (!w || !target) { return false; } AnchorsBase *base = AnchorsBasePrivate::getWidgetAnchorsBase(w); if (!base) { base = new AnchorsBase(w); } return base->setAnchor(p, target, point); } void AnchorsBase::clearAnchors(const QWidget *w) { AnchorsBase *base = AnchorsBasePrivate::getWidgetAnchorsBase(w); if (base) { delete base; } } AnchorsBase *AnchorsBase::getAnchorBaseByWidget(const QWidget *w) { return AnchorsBasePrivate::getWidgetAnchorsBase(w); } void AnchorsBase::setEnabled(bool enabled) { Q_D(AnchorsBase); if (!d->extendWidget) return; d->extendWidget->setEnabled(enabled); } bool AnchorsBase::setAnchor(const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point) { if (!target) { return false; } AnchorsBase *base = AnchorsBasePrivate::getWidgetAnchorsBase(target); if (!base) { base = new AnchorsBase(target); } const AnchorInfo *info = base->d_func()->getInfoByPoint(point); switch (p) { case Qt::AnchorTop: return setTop(info); case Qt::AnchorBottom: return setBottom(info); case Qt::AnchorLeft: return setLeft(info); case Qt::AnchorRight: return setRight(info); case Qt::AnchorHorizontalCenter: return setHorizontalCenter(info); case Qt::AnchorVerticalCenter: return setVerticalCenter(info); default: return false; } } #define ANCHOR_BIND_INFO(point, Point, slotName, ...)\ Q_D(AnchorsBase);\ if(*d->point == point)\ return true;\ DEnhancedWidget *tmp_w1 = NULL;\ DEnhancedWidget *tmp_w2 = NULL;\ if(d->point->targetInfo){\ tmp_w1 = d->point->targetInfo->base->d_func()->extendWidget;\ }\ QStringList signalList = QString(#__VA_ARGS__).split("),");\ if(point){\ if(!d->isBindable(d->point)){\ d->errorCode = Conflict;\ d->errorString = "Conflict: CenterIn or Fill is anchored.";\ return false;\ }\ if (point->base == d->q_func()){\ d->errorCode = TargetInvalid;\ d->errorString = "Cannot anchor widget to self.";\ return false;\ }else if(target()->parentWidget() != point->base->target()){\ bool isBrother = false;\ Q_FOREACH (const QWidget *w, target()->parentWidget()->findChildren()) {\ if(w == point->base->target()){\ isBrother = true;\ break;\ }\ }\ if(!isBrother){\ d->errorCode = TargetInvalid;\ d->errorString = "Cannot anchor to an widget that isn't a parent or sibling.";\ return false;\ }\ }\ if(!d->checkInfo(d->point, point)){\ d->errorCode = PointInvalid;\ d->errorString = "Cannot anchor a vertical/horizontal edge to a horizontal/vertical edge.";\ return false;\ }\ int old_pos = d->getValueByInfo(point);\ AnchorInfo old_info = *d->point;\ *d->point = point;\ slotName();\ if(old_pos != d->getValueByInfo(point)){\ *d->point = old_info;\ slotName();\ d->errorCode = PointInvalid;\ d->errorString = "loop bind.";\ return false;\ }else{\ old_pos = d->getValueByInfo(d->point);\ int target_old_value = d->getValueByInfo(point);\ d->setValueByInfo(target_old_value + 1, point);\ if(old_pos != d->getValueByInfo(d->point)){\ *d->point = old_info;\ slotName();\ d->setValueByInfo(target_old_value, point);\ d->errorCode = PointInvalid;\ d->errorString = "loop bind.";\ return false;\ }\ d->setValueByInfo(target_old_value, point);\ }\ tmp_w2 = point->base->d_func()->extendWidget;\ if(tmp_w1 != tmp_w2){\ Q_FOREACH(QString str, signalList){\ QByteArray arr = str.replace(" ", "").toLatin1();\ if(arr.right(1) != ")") arr += ")";\ if(tmp_w1) {\ disconnect(tmp_w1, QByteArray("2"+arr).data(), d->q_func(), SLOT(slotName()));\ disconnect(tmp_w1, SIGNAL(showed()), d->q_func(), SLOT(slotName()));\ }\ if(arr.size() != 13 || target()->parentWidget() != point->base->target()) {\ connect(tmp_w2, QByteArray("2"+arr).data(), d->q_func(), SLOT(slotName()));\ connect(tmp_w2, SIGNAL(showed()), d->q_func(), SLOT(slotName()));\ }\ }\ }\ }else{\ Q_FOREACH(QString str, signalList){\ QByteArray arr = str.replace(" ", "").toLatin1();\ if(arr.right(1) != ")") arr += ")";\ disconnect(tmp_w1, QByteArray("2"+arr).data(), d->q_func(), SLOT(slotName()));\ disconnect(tmp_w1, SIGNAL(showed()), d->q_func(), SLOT(slotName()));\ }\ *d->point = point;\ }\ if((isBinding(d->right) || isBinding(d->horizontalCenter)) && d->horizontalAnchorCount() == 1)\ {connect(d->extendWidget, SIGNAL(widthChanged(int)), d->q_func(), SLOT(updateHorizontal()));}\ else disconnect(d->extendWidget, SIGNAL(widthChanged(int)), d->q_func(), SLOT(updateHorizontal()));\ if((isBinding(d->bottom) || isBinding(d->verticalCenter)) && d->verticalAnchorCount() == 1)\ {connect(d->extendWidget, SIGNAL(heightChanged(int)), d->q_func(), SLOT(updateVertical()));}\ else disconnect(d->extendWidget, SIGNAL(heightChanged(int)), d->q_func(), SLOT(updateVertical()));\ Q_EMIT point##Changed(d->point);\ return true;\ #define ANCHOR_BIND_WIDGET(point, Point)\ if(d->point->target() == point)\ return true;\ if(point){\ if (point == target()){\ d->errorCode = TargetInvalid;\ d->errorString = "Cannot anchor widget to self.";\ return false;\ }else if(target()->parentWidget() != point){\ bool isBrother = false;\ Q_FOREACH (const QWidget *w, target()->parentWidget()->findChildren()) {\ if(w == point){\ isBrother = true;\ break;\ }\ }\ if(!isBrother){\ d->errorCode = TargetInvalid;\ d->errorString = "Cannot anchor to an widget that isn't a parent or sibling.";\ return false;\ }\ }\ QRect old_rect = point->geometry();\ QWidget *old_widget = d->point->target();\ d->point->setTarget(point);\ update##Point();\ if(old_rect != point->geometry()){\ d->point->setTarget(old_widget);\ update##Point();\ d->errorCode = PointInvalid;\ d->errorString = "loop bind.";\ return false;\ }\ AnchorInfo *info = NULL;\ setTop(info);setLeft(info);setRight(info);setBottom(info);setHorizontalCenter(info);setVerticalCenter(info);setCenterIn((QWidget*)NULL);\ if(d->point == d->fill)\ setCenterIn((QWidget*)NULL);\ if(target()->parentWidget() == point)\ disconnect(d->point, SIGNAL(positionChanged(QPoint)), d->q_func(), SLOT(update##Point()));\ else connect(d->point, SIGNAL(positionChanged(QPoint)), d->q_func(), SLOT(update##Point()));\ }\ d->point->setTarget(point);\ if(d->centerIn){connect(d->extendWidget, SIGNAL(sizeChanged(QSize)), d->q_func(), SLOT(updateCenterIn()));}\ else disconnect(d->extendWidget, SIGNAL(sizeChanged(QSize)), d->q_func(), SLOT(updateCenterIn()));\ Q_EMIT point##Changed(point);\ return true;\ bool AnchorsBase::setTop(const AnchorInfo *top) { ANCHOR_BIND_INFO(top, Top, updateVertical , yChanged(int), heightChanged(int)) } bool AnchorsBase::setBottom(const AnchorInfo *bottom) { ANCHOR_BIND_INFO(bottom, Bottom, updateVertical , yChanged(int), heightChanged(int)) } bool AnchorsBase::setLeft(const AnchorInfo *left) { ANCHOR_BIND_INFO(left, Left, updateHorizontal, xChanged(int), widthChanged(int)) } bool AnchorsBase::setRight(const AnchorInfo *right) { ANCHOR_BIND_INFO(right, Right, updateHorizontal, xChanged(int), widthChanged(int)) } bool AnchorsBase::setHorizontalCenter(const AnchorInfo *horizontalCenter) { ANCHOR_BIND_INFO(horizontalCenter, HorizontalCenter, updateHorizontal, xChanged(int), widthChanged(int)) } bool AnchorsBase::setVerticalCenter(const AnchorInfo *verticalCenter) { ANCHOR_BIND_INFO(verticalCenter, VerticalCenter, updateVertical , yChanged(int), heightChanged(int)) } bool AnchorsBase::setFill(QWidget *fill) { Q_D(AnchorsBase); ANCHOR_BIND_WIDGET(fill, Fill) } bool AnchorsBase::setCenterIn(QWidget *centerIn) { Q_D(AnchorsBase); if (centerIn && d->fill->target()) { d->errorCode = Conflict; d->errorString = "Conflict: Fill is anchored."; return false; } ANCHOR_BIND_WIDGET(centerIn, CenterIn) } bool AnchorsBase::setFill(AnchorsBase *fill) { return setFill(fill->target()); } bool AnchorsBase::setCenterIn(AnchorsBase *centerIn) { return setCenterIn(centerIn->target()); } void AnchorsBase::setMargins(int margins) { Q_D(AnchorsBase); if (d->margins == margins) { return; } d->margins = margins; if (margins != 0) { if (d->fill->target()) { updateFill(); } else { updateVertical(); updateHorizontal(); } } Q_EMIT marginsChanged(margins); } void AnchorsBase::setTopMargin(int topMargin) { Q_D(AnchorsBase); if (d->topMargin == topMargin) { return; } d->topMargin = topMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->top)) { updateVertical(); } Q_EMIT topMarginChanged(topMargin); } void AnchorsBase::setBottomMargin(int bottomMargin) { Q_D(AnchorsBase); if (d->bottomMargin == bottomMargin) { return; } d->bottomMargin = bottomMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->bottom)) { updateVertical(); } Q_EMIT bottomMarginChanged(bottomMargin); } void AnchorsBase::setLeftMargin(int leftMargin) { Q_D(AnchorsBase); if (d->leftMargin == leftMargin) { return; } d->leftMargin = leftMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->left)) { updateHorizontal(); } Q_EMIT leftMarginChanged(leftMargin); } void AnchorsBase::setRightMargin(int rightMargin) { Q_D(AnchorsBase); if (d->rightMargin == rightMargin) { return; } d->rightMargin = rightMargin; if (isBinding(d->right)) { updateHorizontal(); } if (d->fill->target()) { updateFill(); } Q_EMIT rightMarginChanged(rightMargin); } void AnchorsBase::setHorizontalCenterOffset(int horizontalCenterOffset) { Q_D(AnchorsBase); if (d->horizontalCenterOffset == horizontalCenterOffset) { return; } d->horizontalCenterOffset = horizontalCenterOffset; if (isBinding(d->horizontalCenter)) { updateHorizontal(); } Q_EMIT horizontalCenterOffsetChanged(horizontalCenterOffset); } void AnchorsBase::setVerticalCenterOffset(int verticalCenterOffset) { Q_D(AnchorsBase); if (d->verticalCenterOffset == verticalCenterOffset) { return; } d->verticalCenterOffset = verticalCenterOffset; if (isBinding(d->verticalCenter)) { updateVertical(); } Q_EMIT verticalCenterOffsetChanged(verticalCenterOffset); } void AnchorsBase::setAlignWhenCentered(bool alignWhenCentered) { Q_D(AnchorsBase); if (d->alignWhenCentered == alignWhenCentered) { return; } d->alignWhenCentered = alignWhenCentered; Q_EMIT alignWhenCenteredChanged(alignWhenCentered); } #define SET_POS(fun)\ ARect rect = target()->geometry();\ rect.set##fun(arg, point);\ target()->setMinimumSize(QSize(0,0));\ target()->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));\ target()->setGeometry(rect);\ #define MOVE_POS(fun)\ ARect rect = target()->geometry();\ rect.move##fun(arg);\ target()->move(rect.topLeft());\ void AnchorsBase::setTop(int arg, Qt::AnchorPoint point) { SET_POS(Top) } void AnchorsBase::setBottom(int arg, Qt::AnchorPoint point) { SET_POS(Bottom) } void AnchorsBase::setLeft(int arg, Qt::AnchorPoint point) { SET_POS(Left) } void AnchorsBase::setHorizontalCenter(int arg, Qt::AnchorPoint point) { SET_POS(HorizontalCenter) } void AnchorsBase::setVerticalCenter(int arg, Qt::AnchorPoint point) { SET_POS(VerticalCenter) } void AnchorsBase::setRight(int arg, Qt::AnchorPoint point) { SET_POS(Right) } void AnchorsBase::moveTop(int arg) { MOVE_POS(Top) } void AnchorsBase::moveBottom(int arg) { MOVE_POS(Bottom) } void AnchorsBase::moveLeft(int arg) { MOVE_POS(Left) } void AnchorsBase::moveRight(int arg) { MOVE_POS(Right) } void AnchorsBase::moveHorizontalCenter(int arg) { MOVE_POS(HorizontalCenter) } void AnchorsBase::moveVerticalCenter(int arg) { MOVE_POS(VerticalCenter) } void AnchorsBase::moveCenter(const QPoint &arg) { MOVE_POS(Center) } #define UPDATE_GEOMETRY(p1,P1,p2,P2,p3,P3)\ Q_D(AnchorsBase);\ if(isBinding(d->p1)){\ int p1##Value = d->getTargetValueByInfo(d->p1);\ move##P1(p1##Value);\ if(isBinding(d->p2)){\ qreal value = d->getTargetValueByInfo(d->p2);\ set##P3(2 * value - p1##Value, Qt::Anchor##P1);\ }else if(isBinding(d->p3)){\ set##P3(d->getTargetValueByInfo(d->p3), Qt::Anchor##P1);\ }\ }else if(isBinding(d->p3)){\ int p3##Value = d->getTargetValueByInfo(d->p3);\ move##P3(p3##Value);\ if(isBinding(d->p2)){\ qreal value = d->getTargetValueByInfo(d->p2);\ set##P1(2 * value - p3##Value, Qt::Anchor##P1);\ }\ }else if(isBinding(d->p2)){\ move##P2(d->getTargetValueByInfo(d->p2));\ }\ void AnchorsBase::updateVertical() { UPDATE_GEOMETRY(top, Top, verticalCenter, VerticalCenter, bottom, Bottom) } void AnchorsBase::updateHorizontal() { UPDATE_GEOMETRY(left, Left, horizontalCenter, HorizontalCenter, right, Right) } void AnchorsBase::updateFill() { Q_D(AnchorsBase); QRect rect = d->getWidgetRect(d->fill->target()); int offset = d->topMargin != 0 ? d->topMargin : d->margins; rect.setTop(rect.top() + offset); offset = d->bottomMargin != 0 ? d->bottomMargin : d->margins; rect.setBottom(rect.bottom() - offset); offset = d->leftMargin != 0 ? d->leftMargin : d->margins; rect.setLeft(rect.left() + offset); offset = d->rightMargin != 0 ? d->rightMargin : d->margins; rect.setRight(rect.right() - offset); target()->setFixedSize(rect.size()); target()->move(rect.topLeft()); } void AnchorsBase::updateCenterIn() { Q_D(AnchorsBase); QRect rect = d->getWidgetRect(d->centerIn->target()); moveCenter(rect.center()); } void AnchorsBase::init(QWidget *w) { Q_D(AnchorsBase); AnchorsBase *base = AnchorsBasePrivate::getWidgetAnchorsBase(w); if (base) { d_ptr = base->d_ptr; } else if (d && d->q_func() == this) { d->removeWidgetAnchorsBase(target(), this); d->setWidgetAnchorsBase(w, this); d->extendWidget->setTarget(w); } else { base = new AnchorsBase(w, false); d_ptr = base->d_ptr; } } AnchorsBase::AnchorsBase(QWidget *w, bool): QObject(w), d_ptr(new AnchorsBasePrivate(this)) { Q_D(AnchorsBase); d->extendWidget = new DEnhancedWidget(w, this); connect(d->extendWidget, SIGNAL(enabledChanged(bool)), SIGNAL(enabledChanged(bool))); connect(d->fill, SIGNAL(sizeChanged(QSize)), SLOT(updateFill())); connect(d->centerIn, SIGNAL(sizeChanged(QSize)), SLOT(updateCenterIn())); connect(d->fill, SIGNAL(showed()), SLOT(updateFill())); connect(d->centerIn, SIGNAL(showed()), SLOT(updateCenterIn())); d->setWidgetAnchorsBase(w, this); } void ARect::setTop(int arg, Qt::AnchorPoint point) { if (point == Qt::AnchorVerticalCenter) { QRect::setBottom(bottom() + arg - top()); } QRect::setTop(arg); } void ARect::setVerticalCenter(qreal arg, Qt::AnchorPoint point) { if (point == Qt::AnchorTop) { QRect::setBottom(2 * arg - top()); } else if (point == Qt::AnchorBottom) { QRect::setTop(2 * arg - bottom()); } } void ARect::setBottom(int arg, Qt::AnchorPoint point) { if (point == Qt::AnchorVerticalCenter) { setHeight(arg - bottom()); } QRect::setBottom(arg); } void ARect::setLeft(int arg, Qt::AnchorPoint point) { if (point == Qt::AnchorHorizontalCenter) { setWidth(left() - arg); } QRect::setLeft(arg); } void ARect::setHorizontalCenter(qreal arg, Qt::AnchorPoint point) { if (point == Qt::AnchorLeft) { QRect::setRight(2 * arg - left()); } else if (point == Qt::AnchorRight) { QRect::setLeft(2 * arg - right()); } } void ARect::setRight(int arg, Qt::AnchorPoint point) { if (point == Qt::AnchorHorizontalCenter) { setWidth(arg - right()); } QRect::setRight(arg); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/anchors.h000066400000000000000000000224241325435343100177200ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef ANCHORS_H #define ANCHORS_H #include #include #include #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class AnchorsBase; struct D_DECL_DEPRECATED AnchorInfo { AnchorInfo(AnchorsBase *b, const Qt::AnchorPoint &t): base(b), type(t) { } AnchorsBase *base; Qt::AnchorPoint type; const AnchorInfo *targetInfo = NULL; bool operator==(const AnchorInfo *info) const { return info == targetInfo; } bool operator==(const AnchorInfo &info) const { return &info == targetInfo; } bool operator!=(const AnchorInfo *info) const { return info != targetInfo; } bool operator!=(const AnchorInfo &info) const { return &info != targetInfo; } const AnchorInfo &operator=(const AnchorInfo *info) { targetInfo = info; return *this; } }; class D_DECL_DEPRECATED ARect: public QRect { public: ARect() {} ARect(const QRect &rect): QRect(rect.topLeft(), rect.bottomRight()) {} const QRect &operator=(const QRect &rect) { setTopLeft(rect.topLeft()); setBottomRight(rect.bottomRight()); return *this; } inline qreal horizontalCenter() { return left() + width() / 2.0; } inline void moveHorizontalCenter(int arg) { moveLeft(arg - width() / 2.0); } inline qreal verticalCenter() { return top() + height() / 2.0; } inline void moveVerticalCenter(int arg) { moveTop(arg - height() / 2.0); } void setTop(int arg, Qt::AnchorPoint point); void setVerticalCenter(qreal arg, Qt::AnchorPoint point); void setBottom(int arg, Qt::AnchorPoint point); void setLeft(int arg, Qt::AnchorPoint point); void setHorizontalCenter(qreal arg, Qt::AnchorPoint point); void setRight(int arg, Qt::AnchorPoint point); }; class AnchorsBasePrivate; class DEnhancedWidget; class D_DECL_DEPRECATED AnchorsBase : public QObject { Q_OBJECT Q_PROPERTY(QWidget *target READ target CONSTANT) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(const AnchorsBase *anchors READ anchors) Q_PROPERTY(const AnchorInfo *top READ top WRITE setTop NOTIFY topChanged) Q_PROPERTY(const AnchorInfo *bottom READ bottom WRITE setBottom NOTIFY bottomChanged) Q_PROPERTY(const AnchorInfo *left READ left WRITE setLeft NOTIFY leftChanged) Q_PROPERTY(const AnchorInfo *right READ right WRITE setRight NOTIFY rightChanged) Q_PROPERTY(const AnchorInfo *horizontalCenter READ horizontalCenter WRITE setHorizontalCenter NOTIFY horizontalCenterChanged) Q_PROPERTY(const AnchorInfo *verticalCenter READ verticalCenter WRITE setVerticalCenter NOTIFY verticalCenterChanged) Q_PROPERTY(QWidget *fill READ fill WRITE setFill NOTIFY fillChanged) Q_PROPERTY(QWidget *centerIn READ centerIn WRITE setCenterIn NOTIFY centerInChanged) Q_PROPERTY(int margins READ margins WRITE setMargins NOTIFY marginsChanged) Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) Q_PROPERTY(int horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged) Q_PROPERTY(int verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged) Q_PROPERTY(bool alignWhenCentered READ alignWhenCentered WRITE setAlignWhenCentered NOTIFY alignWhenCenteredChanged) public: explicit AnchorsBase(QWidget *w); ~AnchorsBase(); enum AnchorError { NoError, Conflict, TargetInvalid, PointInvalid, LoopBind }; QWidget *target() const; DEnhancedWidget *enhancedWidget() const; bool enabled() const; const AnchorsBase *anchors() const; const AnchorInfo *top() const; const AnchorInfo *bottom() const; const AnchorInfo *left() const; const AnchorInfo *right() const; const AnchorInfo *horizontalCenter() const; const AnchorInfo *verticalCenter() const; QWidget *fill() const; QWidget *centerIn() const; int margins() const; int topMargin() const; int bottomMargin() const; int leftMargin() const; int rightMargin() const; int horizontalCenterOffset() const; int verticalCenterOffset() const; int alignWhenCentered() const; AnchorError errorCode() const; QString errorString() const; bool isBinding(const AnchorInfo *info) const; static bool setAnchor(QWidget *w, const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point); static void clearAnchors(const QWidget *w); static AnchorsBase *getAnchorBaseByWidget(const QWidget *w); public Q_SLOTS: void setEnabled(bool enabled); bool setAnchor(const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point); bool setTop(const AnchorInfo *top); bool setBottom(const AnchorInfo *bottom); bool setLeft(const AnchorInfo *left); bool setRight(const AnchorInfo *right); bool setHorizontalCenter(const AnchorInfo *horizontalCenter); bool setVerticalCenter(const AnchorInfo *verticalCenter); bool setFill(QWidget *fill); bool setCenterIn(QWidget *centerIn); bool setFill(AnchorsBase *fill); bool setCenterIn(AnchorsBase *centerIn); void setMargins(int margins); void setTopMargin(int topMargin); void setBottomMargin(int bottomMargin); void setLeftMargin(int leftMargin); void setRightMargin(int rightMargin); void setHorizontalCenterOffset(int horizontalCenterOffset); void setVerticalCenterOffset(int verticalCenterOffset); void setAlignWhenCentered(bool alignWhenCentered); void setTop(int arg, Qt::AnchorPoint point); void setBottom(int arg, Qt::AnchorPoint point); void setLeft(int arg, Qt::AnchorPoint point); void setRight(int arg, Qt::AnchorPoint point); void setHorizontalCenter(int arg, Qt::AnchorPoint point); void setVerticalCenter(int arg, Qt::AnchorPoint point); void moveTop(int arg); void moveBottom(int arg); void moveLeft(int arg); void moveRight(int arg); void moveHorizontalCenter(int arg); void moveVerticalCenter(int arg); void moveCenter(const QPoint &arg); private Q_SLOTS: void updateVertical(); void updateHorizontal(); void updateFill(); void updateCenterIn(); Q_SIGNALS: void enabledChanged(bool enabled); void topChanged(const AnchorInfo *top); void bottomChanged(const AnchorInfo *bottom); void leftChanged(const AnchorInfo *left); void rightChanged(const AnchorInfo *right); void horizontalCenterChanged(const AnchorInfo *horizontalCenter); void verticalCenterChanged(const AnchorInfo *verticalCenter); void fillChanged(QWidget *fill); void centerInChanged(QWidget *centerIn); void marginsChanged(int margins); void topMarginChanged(int topMargin); void bottomMarginChanged(int bottomMargin); void leftMarginChanged(int leftMargin); void rightMarginChanged(int rightMargin); void horizontalCenterOffsetChanged(int horizontalCenterOffset); void verticalCenterOffsetChanged(int verticalCenterOffset); void alignWhenCenteredChanged(bool alignWhenCentered); protected: void init(QWidget *w); private: AnchorsBase(QWidget *w, bool); QExplicitlySharedDataPointer d_ptr; Q_DECLARE_PRIVATE(AnchorsBase) }; template class D_DECL_DEPRECATED Anchors : public AnchorsBase { public: inline Anchors(): AnchorsBase((QWidget*)NULL), m_widget(NULL) {} inline Anchors(T *w): AnchorsBase(w), m_widget(w) {} inline Anchors(const Anchors &me): AnchorsBase(me.m_widget), m_widget(me.m_widget) {} inline T &operator=(const Anchors &me) { m_widget = me.m_widget; init(m_widget); return *m_widget; } inline T &operator=(T *w) { m_widget = w; init(w); return *m_widget; } inline T *widget() const { return m_widget; } inline T *operator ->() const { return m_widget; } inline T &operator *() const { return *m_widget; } inline operator T *() const { return m_widget; } inline operator T &() const { return *m_widget; } private: T *m_widget; }; DWIDGET_END_NAMESPACE #endif // ANCHORS_H dtkwidget-2.0.7.2/src/widgets/daboutdialog.cpp000066400000000000000000000273051325435343100212570ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "daboutdialog.h" #include "private/daboutdialog_p.h" #include "dthememanager.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef Q_OS_UNIX #include #include #endif DWIDGET_BEGIN_NAMESPACE #ifdef Q_OS_UNIX class EnvReplaceGuard { public: EnvReplaceGuard(const int uid); ~EnvReplaceGuard(); char *m_backupLogName; char *m_backupHome; }; EnvReplaceGuard::EnvReplaceGuard(const int uid) { m_backupLogName = getenv("LOGNAME"); m_backupHome = getenv("HOME"); struct passwd *pwd = getpwuid(uid); setenv("LOGNAME", pwd->pw_name, 1); setenv("HOME", pwd->pw_dir, 1); } EnvReplaceGuard::~EnvReplaceGuard() { setenv("LOGNAME", m_backupLogName, 1); setenv("HOME", m_backupHome, 1); } #endif const QString DAboutDialogPrivate::websiteLinkTemplate = "%2"; DAboutDialogPrivate::DAboutDialogPrivate(DAboutDialog *qq) : DDialogPrivate(qq) { } void DAboutDialogPrivate::init() { D_Q(DAboutDialog); initWebsiteInfo(); logoLabel = new QLabel(); logoLabel->setContentsMargins(0, 0, 0, 0); productNameLabel = new QLabel(); productNameLabel->setObjectName("ProductNameLabel"); versionLabel = new QLabel(); versionLabel->setObjectName("VersionLabel"); companyLogoLabel = new QLabel(); companyLogoLabel->setPixmap(loadPixmap(":/images/deepin-logo.svg")); websiteLabel = new QLabel(); websiteLabel->setObjectName("WebsiteLabel"); websiteLabel->setContextMenuPolicy(Qt::NoContextMenu); websiteLabel->setFixedHeight(24); websiteLabel->setOpenExternalLinks(false); updateWebsiteLabel(); acknowledgementLabel = new QLabel(); acknowledgementLabel->setObjectName("AcknowledgementLabel"); acknowledgementLabel->setContextMenuPolicy(Qt::NoContextMenu); acknowledgementLabel->setFixedHeight(24); acknowledgementLabel->setOpenExternalLinks(false); updateAcknowledgementLabel(); descriptionLabel = new QLabel(); descriptionLabel->setObjectName("DescriptionLabel"); descriptionLabel->setAlignment(Qt::AlignHCenter); descriptionLabel->setWordWrap(true); descriptionLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); licenseLabel = new QLabel(); licenseLabel->setObjectName("LicenseLabel"); licenseLabel->setAlignment(Qt::AlignHCenter); licenseLabel->setWordWrap(true); licenseLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); licenseLabel->hide(); q->connect(websiteLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onLinkActivated(QString))); q->connect(acknowledgementLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onLinkActivated(QString))); q->connect(descriptionLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onLinkActivated(QString))); q->connect(licenseLabel, SIGNAL(linkActivated(QString)), q, SLOT(_q_onLinkActivated(QString))); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setContentsMargins(11, 20, 11, 10); mainLayout->setSpacing(0); mainLayout->addWidget(logoLabel); mainLayout->setAlignment(logoLabel, Qt::AlignCenter); mainLayout->addSpacing(3); mainLayout->addWidget(productNameLabel); mainLayout->setAlignment(productNameLabel, Qt::AlignCenter); mainLayout->addSpacing(6); mainLayout->addWidget(versionLabel); mainLayout->setAlignment(versionLabel, Qt::AlignCenter); mainLayout->addSpacing(8); mainLayout->addWidget(companyLogoLabel); mainLayout->setAlignment(companyLogoLabel, Qt::AlignCenter); // mainLayout->addSpacing(6); mainLayout->addWidget(websiteLabel); mainLayout->setAlignment(websiteLabel, Qt::AlignCenter); mainLayout->addSpacing(5); mainLayout->addWidget(acknowledgementLabel); mainLayout->setAlignment(acknowledgementLabel, Qt::AlignCenter); mainLayout->addSpacing(12); mainLayout->addWidget(descriptionLabel, Qt::AlignHCenter); mainLayout->addSpacing(7); mainLayout->addWidget(licenseLabel, Qt::AlignHCenter); QWidget *mainContent = new QWidget; mainContent->setLayout(mainLayout); q->addContent(mainContent); q->setFixedWidth(400); // make active q->setFocus(); } void DAboutDialogPrivate::initWebsiteInfo() { #ifdef Q_OS_LINUX static const QString cfgPath = "/etc/deepin-version"; bool isProfessional = false; if (QFile::exists(cfgPath)) { QSettings deepinVersion(cfgPath, QSettings::IniFormat); isProfessional = deepinVersion.value("Release/Type").toString() == "Professional"; } websiteName = isProfessional ? "www.deepin.com" : "www.deepin.org"; websiteLink = QString("https://www.deepin.org/original/%1/").arg(qApp->applicationName()); #else websiteName = "www.deepin.org"; websiteLink = "https://www.deepin.org"; #endif } void DAboutDialogPrivate::updateWebsiteLabel() { QString websiteText = QString(websiteLinkTemplate).arg(websiteLink).arg(websiteName); websiteLabel->setText(websiteText); } void DAboutDialogPrivate::updateAcknowledgementLabel() { QString acknowledgementText = QString(websiteLinkTemplate).arg(acknowledgementLink).arg(QApplication::translate("DAboutDialog", "Acknowledgements")); acknowledgementLabel->setText(acknowledgementText); } void DAboutDialogPrivate::_q_onLinkActivated(const QString &link) { #ifdef Q_OS_UNIX // workaround for pkexec apps bool ok = false; const int pkexecUid = qEnvironmentVariableIntValue("PKEXEC_UID", &ok); if (ok) { EnvReplaceGuard _env_guard(pkexecUid); Q_UNUSED(_env_guard); QDesktopServices::openUrl(QUrl(link)); } else #endif { QDesktopServices::openUrl(QUrl(link)); } } QPixmap DAboutDialogPrivate::loadPixmap(const QString &file) { D_Q(DAboutDialog); qreal ratio = 1.0; const qreal devicePixelRatio = q->devicePixelRatioF(); QPixmap pixmap; if (!qFuzzyCompare(ratio, devicePixelRatio)) { QImageReader reader; reader.setFileName(qt_findAtNxFile(file, devicePixelRatio, &ratio)); if (reader.canRead()) { reader.setScaledSize(reader.size() * (devicePixelRatio / ratio)); pixmap = QPixmap::fromImage(reader.read()); pixmap.setDevicePixelRatio(devicePixelRatio); } } else { pixmap.load(file); } return pixmap; } DAboutDialog::DAboutDialog(QWidget *parent) : DDialog(*new DAboutDialogPrivate(this), parent) { DThemeManager::registerWidget(this); D_D(DAboutDialog); d->init(); d->productNameLabel->setStyleSheet(styleSheet()); d->versionLabel->setStyleSheet(styleSheet()); d->websiteLabel->setStyleSheet(styleSheet()); d->acknowledgementLabel->setStyleSheet(styleSheet()); d->descriptionLabel->setStyleSheet(styleSheet()); d->licenseLabel->setStyleSheet(styleSheet()); } /*! * \property DAboutDialog::windowTitle * * \brief the title of the dialog. */ QString DAboutDialog::windowTitle() const { return title(); } /*! * \property DAboutDialog::productName * * \brief the product name to be shown on the dialog. */ QString DAboutDialog::productName() const { D_DC(DAboutDialog); return d->productNameLabel->text(); } /*! * \property DAboutDialog::version * * \brief the version number to be shown on the dialog. */ QString DAboutDialog::version() const { D_DC(DAboutDialog); return d->versionLabel->text(); } /*! * \property DAboutDialog::description * \brief the description to be show on the dialog. */ QString DAboutDialog::description() const { D_DC(DAboutDialog); return d->descriptionLabel->text(); } /*! * \property DAboutDialog::companyLogo * \brief the vendor logo to be shown on the dialog. */ const QPixmap *DAboutDialog::companyLogo() const { D_DC(DAboutDialog); return d->companyLogoLabel->pixmap(); } /*! * \property DAboutDialog::websiteName * \brief the vendor website name to be shown on the dialog. * * Usually be in form like www.deepin.org. */ QString DAboutDialog::websiteName() const { D_DC(DAboutDialog); return d->websiteName; } /*! * \property DAboutDialog::websiteLink * \brief the corresponding web address of websiteName() * * The website link will be open in the browser if the user clicks on * the website text shown on the dialog. */ QString DAboutDialog::websiteLink() const { D_DC(DAboutDialog); return d->websiteLink; } /*! * \property DAboutDialog::acknowledgementLink * \brief the web address to be open open when user clicks on the "Acknowlegement" * text show on the dialog. */ QString DAboutDialog::acknowledgementLink() const { D_DC(DAboutDialog); return d->acknowledgementLink; } /*! * \property DAboutDialog::license * \brief the license to be shown on the dialog. */ QString DAboutDialog::license() const { D_DC(DAboutDialog); return d->licenseLabel->text(); } void DAboutDialog::setWindowTitle(const QString &windowTitle) { setTitle(windowTitle); } void DAboutDialog::setProductIcon(const QIcon &icon) { D_D(DAboutDialog); d->logoLabel->setPixmap(icon.pixmap(QSizeF(96, 96).toSize())); } void DAboutDialog::setProductName(const QString &productName) { D_D(DAboutDialog); d->productNameLabel->setText(productName); } void DAboutDialog::setVersion(const QString &version) { D_D(DAboutDialog); d->versionLabel->setText(version); } void DAboutDialog::setDescription(const QString &description) { D_D(DAboutDialog); d->descriptionLabel->setText(description); } void DAboutDialog::setCompanyLogo(const QPixmap &companyLogo) { D_D(DAboutDialog); d->companyLogoLabel->setPixmap(companyLogo); d->companyLogoLabel->setFixedSize(companyLogo.size()); } void DAboutDialog::setWebsiteName(const QString &websiteName) { D_D(DAboutDialog); if (d->websiteName == websiteName) { return; } d->websiteName = websiteName; d->updateWebsiteLabel(); } void DAboutDialog::setWebsiteLink(const QString &websiteLink) { D_D(DAboutDialog); if (d->websiteLink == websiteLink) { return; } d->websiteLink = websiteLink; d->updateWebsiteLabel(); } void DAboutDialog::setAcknowledgementLink(const QString &acknowledgementLink) { D_D(DAboutDialog); d->acknowledgementLink = acknowledgementLink; d->updateAcknowledgementLabel(); } void DAboutDialog::setLicense(const QString &license) { D_D(DAboutDialog); d->licenseLabel->setText(license); d->licenseLabel->setVisible(!license.isEmpty()); } void DAboutDialog::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Escape) { close(); event->accept(); } DDialog::keyPressEvent(event); } void DAboutDialog::showEvent(QShowEvent *event) { DDialog::showEvent(event); if (minimumWidth() == maximumWidth()) { resize(width(), heightForWidth(width())); } else { adjustSize(); } } #include "moc_daboutdialog.cpp" DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/daboutdialog.h000066400000000000000000000051751325435343100207250ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DABOUTDIALOG_H #define DABOUTDIALOG_H #include "ddialog.h" DWIDGET_BEGIN_NAMESPACE class DAboutDialogPrivate; class DAboutDialog : public DDialog { Q_OBJECT Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle) Q_PROPERTY(QString productName READ productName WRITE setProductName) Q_PROPERTY(QString version READ version WRITE setVersion) Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QString license READ license WRITE setLicense) Q_PROPERTY(QString websiteName READ websiteName WRITE setWebsiteName) Q_PROPERTY(QString websiteLink READ websiteLink WRITE setWebsiteLink) Q_PROPERTY(QString acknowledgementLink READ acknowledgementLink WRITE setAcknowledgementLink) public: DAboutDialog(QWidget *parent = 0); QString windowTitle() const; QString productName() const; QString version() const; QString description() const; const QPixmap *companyLogo() const; QString websiteName() const; QString websiteLink() const; QString acknowledgementLink() const; QString license() const; public Q_SLOTS: void setWindowTitle(const QString &windowTitle); void setProductIcon(const QIcon &icon); void setProductName(const QString &productName); void setVersion(const QString &version); void setDescription(const QString &description); void setCompanyLogo(const QPixmap &companyLogo); void setWebsiteName(const QString &websiteName); void setWebsiteLink(const QString &websiteLink); void setAcknowledgementLink(const QString &acknowledgementLink); void setLicense(const QString &license); protected: void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; private: Q_PRIVATE_SLOT(d_func(), void _q_onLinkActivated(const QString &link)) Q_DISABLE_COPY(DAboutDialog) D_DECLARE_PRIVATE(DAboutDialog) }; DWIDGET_END_NAMESPACE #endif // DABOUTDIALOG_H dtkwidget-2.0.7.2/src/widgets/dabstractcomboboxdelegate.cpp000066400000000000000000000036111325435343100240060ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dabstractcomboboxdelegate.h" DWIDGET_BEGIN_NAMESPACE DAbstractComboBoxDelegate::DAbstractComboBoxDelegate(QObject *parent) : QStyledItemDelegate(parent) { } void DAbstractComboBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyledItemDelegate::paint(painter, option, index); //TODO, need to find anther way to get current index DComboBox *cb = static_cast(this->parent()); if (cb){ QModelIndex currentIndex = index.model()->index(cb->currentIndex(),0,QModelIndex()); if (index == currentIndex){ QPixmap pixmap((cb->hoverIndex() != currentIndex) ? cb->normalTickImg() : cb->hoverTickImg()); QRect rect = option.rect; rect.setX(TEXT_LEFT_MARGIN); rect.setY(rect.y() + (rect.height() - pixmap.height()) / 2);//draw in vertical center rect.setSize(pixmap.size()); painter->drawPixmap(rect, pixmap); } } } void DAbstractComboBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(index) editor->setGeometry(option.rect); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dabstractcomboboxdelegate.h000066400000000000000000000026511325435343100234560ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DABSTRACTCOMBOBOXDELEGATE_H #define DABSTRACTCOMBOBOXDELEGATE_H #include #include #include #include "dcombobox.h" DWIDGET_BEGIN_NAMESPACE class DAbstractComboBoxDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit DAbstractComboBoxDelegate(QObject *parent = 0); void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; void paint(QPainter * painter,const QStyleOptionViewItem & option,const QModelIndex & index) const; // bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index); }; DWIDGET_END_NAMESPACE #endif // DABSTRACTCOMBOBOXDELEGATE_H dtkwidget-2.0.7.2/src/widgets/dabstractdialog.cpp000066400000000000000000000221231325435343100217410ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include "danchors.h" #include "dialog_constants.h" #include "dabstractdialog.h" #include "private/dabstractdialogprivate_p.h" #include "dthememanager.h" #include "dplatformwindowhandle.h" #include "dapplication.h" #include "dblureffectwidget.h" DWIDGET_BEGIN_NAMESPACE DAbstractDialogPrivate::DAbstractDialogPrivate(DAbstractDialog *qq): DObjectPrivate(qq) { } void DAbstractDialogPrivate::init() { D_Q(DAbstractDialog); if (qApp->isDXcbPlatform()) { handle = new DPlatformWindowHandle(q, q); handle->setTranslucentBackground(true); handle->setEnableSystemMove(false); handle->setEnableSystemResize(false); // bgBlurWidget = new DBlurEffectWidget(q); // bgBlurWidget->lower(); // bgBlurWidget->setBlendMode(DBlurEffectWidget::BehindWindowBlend); // bgBlurWidget->setVisible(DPlatformWindowHandle::hasBlurWindow()); // DPlatformWindowHandle::connectWindowManagerChangedSignal(q, [this] { // bgBlurWidget->setVisible(DPlatformWindowHandle::hasBlurWindow()); // }); } windowTitle = new QLabel(q); windowTitle->setAlignment(Qt::AlignCenter); DAnchorsBase::setAnchor(windowTitle, Qt::AnchorHorizontalCenter, q, Qt::AnchorHorizontalCenter); q->connect(q,&QWidget::windowTitleChanged, windowTitle,[=](const QString &title){ windowTitle->setText(title); }); q->setWindowFlags(q->windowFlags() | Qt::FramelessWindowHint | Qt::WindowCloseButtonHint); q->setAttribute(Qt::WA_TranslucentBackground); q->resize(DIALOG::DEFAULT_WIDTH, DIALOG::DEFAULT_HEIGHT); q->setMaximumWidth(480); q->setAttribute(Qt::WA_Resized, false); q->setBorderColor(QColor(0, 0, 0)); } QRect DAbstractDialogPrivate::getParentGeometry() const { D_QC(DAbstractDialog); if (q->parentWidget()) { return q->parentWidget()->window()->geometry(); } else { QPoint pos = QCursor::pos(); for (QScreen *screen : qApp->screens()) { if (screen->geometry().contains(pos)) { return screen->geometry(); } } } return qApp->primaryScreen()->geometry(); } /** * @brief DAbstractDialog::DAbstractDialog constructs a DAbstractDialog instance. * @param parent is the parent widget to be used. */ DAbstractDialog::DAbstractDialog(QWidget *parent) : QDialog(parent), DObject(*new DAbstractDialogPrivate(this)) { DThemeManager::registerWidget(this); d_func()->init(); } /** * @brief DAbstractDialog::backgroundColor * @return the background color of the dialog. */ QColor DAbstractDialog::backgroundColor() const { D_DC(DAbstractDialog); return d->backgroundColor; } /** * @brief DAbstractDialog::borderColor * @return the border color of the dialog. */ QColor DAbstractDialog::borderColor() const { D_DC(DAbstractDialog); return d->borderColor; } /** * @brief DAbstractDialog::displayPosition * @return the display position of this dialog. */ DAbstractDialog::DisplayPosition DAbstractDialog::displayPosition() const { D_DC(DAbstractDialog); return d->displayPosition; } DAbstractDialog::DisplayPostion DAbstractDialog::displayPostion() const { return static_cast(displayPosition()); } void DAbstractDialog::move(const QPoint &pos) { QDialog::move(pos); D_D(DAbstractDialog); d->mouseMoved = true; } void DAbstractDialog::setGeometry(const QRect &rect) { QDialog::setGeometry(rect); D_D(DAbstractDialog); d->mouseMoved = true; } /** * @brief DAbstractDialog::moveToCenter moves the dialog to the center of the screen or its parent widget. */ void DAbstractDialog::moveToCenter() { D_DC(DAbstractDialog); moveToCenterByRect(d->getParentGeometry()); } /** * @brief DAbstractDialog::moveToTopRight moves the dialog to the top right of the screen or its parent widget. */ void DAbstractDialog::moveToTopRight() { D_DC(DAbstractDialog); moveToTopRightByRect(d->getParentGeometry()); } /** * @brief DAbstractDialog::moveToTopRightByRect moves the dialog to the top right corner of the rect. * @param rect is the target rect. */ void DAbstractDialog::moveToTopRightByRect(const QRect &rect) { int x = rect.x() + rect.width() - width(); QDialog::move(QPoint(x, 0)); } /** * @brief DAbstractDialog::setBackgroundColor sets the background color of the dialog. * @param backgroundColor is the target background color. */ void DAbstractDialog::setBackgroundColor(QColor backgroundColor) { D_D(DAbstractDialog); d->backgroundColor = backgroundColor; if (d->bgBlurWidget) d->bgBlurWidget->setMaskColor(backgroundColor); update(); } /** * @brief DAbstractDialog::setBorderColor sets the border color of the dialog. * @param borderColor is the target border color. */ void DAbstractDialog::setBorderColor(QColor borderColor) { D_D(DAbstractDialog); d->borderColor = borderColor; if (d->handle) { d->handle->setBorderColor(d->borderColor); } else { update(); } } /** * @brief DAbstractDialog::setDisplayPosition sets the position of the dialog. * @param displayPosition is the target position. */ void DAbstractDialog::setDisplayPosition(DAbstractDialog::DisplayPosition displayPosition) { D_D(DAbstractDialog); d->displayPosition = displayPosition; switch (displayPosition) { case DisplayCenter: moveToCenter(); break; case DisplayTopRight: moveToTopRight(); break; default: break; } } void DAbstractDialog::setDisplayPostion(DAbstractDialog::DisplayPostion displayPosition) { setDisplayPosition(static_cast(displayPosition)); } /** * @brief DAbstractDialog::moveToCenterByRect moves the dialog to the center of the rect. * @param rect is the target rect. */ void DAbstractDialog::moveToCenterByRect(const QRect &rect) { QRect qr = geometry(); qr.moveCenter(rect.center()); QDialog::move(qr.topLeft()); } void DAbstractDialog::mousePressEvent(QMouseEvent *event) { D_DC(DAbstractDialog); if (d->handle) { return QDialog::mousePressEvent(event); } if (event->button() == Qt::LeftButton) { D_D(DAbstractDialog); d->dragPosition = event->globalPos() - frameGeometry().topLeft(); d->mousePressed = true; } QDialog::mousePressEvent(event); } void DAbstractDialog::mouseReleaseEvent(QMouseEvent *event) { D_D(DAbstractDialog); if (d->handle) { return QDialog::mouseReleaseEvent(event); } d->mousePressed = false; QDialog::mouseReleaseEvent(event); } void DAbstractDialog::mouseMoveEvent(QMouseEvent *event) { D_D(DAbstractDialog); if (d->handle) { d->handle->setEnableSystemMove(true); return QDialog::mouseMoveEvent(event); } if (d->mousePressed) { move(event->globalPos() - d->dragPosition); d->mouseMoved = true; } QDialog::mouseMoveEvent(event); } void DAbstractDialog::paintEvent(QPaintEvent *event) { D_DC(DAbstractDialog); QPainter painter(this); if (d->handle) { painter.fillRect(event->rect(), d->backgroundColor); } else { painter.setPen(QPen(d->borderColor, DIALOG::BORDER_SHADOW_WIDTH)); painter.setBrush(d->backgroundColor); painter.setRenderHint(QPainter::Antialiasing, true); QRectF r(DIALOG::BORDER_SHADOW_WIDTH / 2.0, DIALOG::BORDER_SHADOW_WIDTH / 2.0, width() - DIALOG::BORDER_SHADOW_WIDTH, height() - DIALOG::BORDER_SHADOW_WIDTH); painter.drawRoundedRect(r, DIALOG::BORDER_RADIUS, DIALOG::BORDER_RADIUS); } QDialog::paintEvent(event); } void DAbstractDialog::resizeEvent(QResizeEvent *event) { if (event->size().width() >= maximumWidth()) { bool resized = testAttribute(Qt::WA_Resized); setFixedWidth(maximumWidth()); if (!resized) setAttribute(Qt::WA_Resized, false); } QDialog::resizeEvent(event); D_DC(DAbstractDialog); if (!d->mouseMoved) { setDisplayPosition(displayPosition()); } if (d->bgBlurWidget) d->bgBlurWidget->resize(event->size()); Q_EMIT sizeChanged(event->size()); } DAbstractDialog::DAbstractDialog(DAbstractDialogPrivate &dd, QWidget *parent): QDialog(parent), DObject(dd) { dd.init(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dabstractdialog.h000066400000000000000000000066061325435343100214160ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DABSTRACTDIALOG_H #define DABSTRACTDIALOG_H #include #include #include #include "dtkwidget_global.h" class QMouseEvent; class QPushButton; class QResizeEvent; DWIDGET_BEGIN_NAMESPACE class DAbstractDialogPrivate; class LIBDTKWIDGETSHARED_EXPORT DAbstractDialog : public QDialog, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) Q_PROPERTY(DisplayPosition displayPosition READ displayPosition WRITE setDisplayPosition) public: /** * @brief The DisplayPosition enum contains the position options that can be specified by all dialogs. */ enum DisplayPosition { Center, /*!< display this dialog in the center of the screen */ TopRight /*!< display this dialog in the top right of the screen */ }; enum DisplayPostion { DisplayCenter = Center, /*!< display this dialog in the center of the screen */ DisplayTopRight = TopRight /*!< display this dialog in the top right of the screen */ }; Q_ENUMS(DisplayPosition) Q_ENUMS(DisplayPostion) DAbstractDialog(QWidget *parent = 0); QColor backgroundColor() const; QColor borderColor() const; DisplayPosition displayPosition() const; D_DECL_DEPRECATED DisplayPostion displayPostion() const; void move(const QPoint &pos); inline void move(int x, int y) { move(QPoint(x, y));} void setGeometry(const QRect &rect); inline void setGeometry(int x, int y, int width, int height) { setGeometry(QRect(x, y, width, height));} public Q_SLOTS: void moveToCenter(); void moveToTopRight(); void moveToCenterByRect(const QRect &rect); void moveToTopRightByRect(const QRect &rect); void setBackgroundColor(QColor backgroundColor); void setBorderColor(QColor borderColor); void setDisplayPosition(DisplayPosition displayPosition); D_DECL_DEPRECATED void setDisplayPostion(DisplayPostion displayPosition); Q_SIGNALS: /** * @brief sizeChanged is emitted when the size of this dialog changed. * @param size is the target size. */ void sizeChanged(QSize size); protected: void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; protected: DAbstractDialog(DAbstractDialogPrivate &dd, QWidget *parent = 0); private: D_DECLARE_PRIVATE(DAbstractDialog) }; DWIDGET_END_NAMESPACE #endif // DABSTRACTDIALOG_H dtkwidget-2.0.7.2/src/widgets/danchors.cpp000066400000000000000000000743171325435343100204270ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * Author: kirigaya * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "danchors.h" #include "denhancedwidget.h" DWIDGET_BEGIN_NAMESPACE class DAnchorsRect: public QRect { public: DAnchorsRect() {} DAnchorsRect(const QRect &rect): QRect(rect.topLeft(), rect.bottomRight()) {} const QRect &operator=(const QRect &rect) { setTopLeft(rect.topLeft()); setBottomRight(rect.bottomRight()); return *this; } inline qreal horizontalCenter() { return left() + width() / 2.0; } inline void moveHorizontalCenter(int arg) { moveLeft(arg - width() / 2.0); } inline qreal verticalCenter() { return top() + height() / 2.0; } inline void moveVerticalCenter(int arg) { moveTop(arg - height() / 2.0); } void setTop(int arg, Qt::AnchorPoint point); void setVerticalCenter(qreal arg, Qt::AnchorPoint point); void setBottom(int arg, Qt::AnchorPoint point); void setLeft(int arg, Qt::AnchorPoint point); void setHorizontalCenter(qreal arg, Qt::AnchorPoint point); void setRight(int arg, Qt::AnchorPoint point); }; class DAnchorsBasePrivate : public QSharedData { DAnchorsBasePrivate(DAnchorsBase *qq): q_ptr(qq) {} ~DAnchorsBasePrivate() { delete top; delete bottom; delete left; delete right; delete horizontalCenter; delete verticalCenter; } static void setWidgetAnchorsBase(const QWidget *w, DAnchorsBase *b) { if (w) { DAnchorsBase *bb = widgetMap.value(w, NULL); if (bb) { bb->deleteLater(); } widgetMap[w] = b; } } static DAnchorsBase *getWidgetAnchorsBase(const QWidget *w) { return widgetMap.value(w, NULL); } static void removeWidgetAnchorsBase(const QWidget *w, const DAnchorsBase *b) { if (w && b && widgetMap.value(w, NULL) == b) { widgetMap.remove(w); } } const DAnchorInfo *getInfoByPoint(const Qt::AnchorPoint &p) const { switch (p) { case Qt::AnchorTop: return top; case Qt::AnchorBottom: return bottom; case Qt::AnchorLeft: return left; case Qt::AnchorRight: return right; case Qt::AnchorHorizontalCenter: return horizontalCenter; case Qt::AnchorVerticalCenter: return verticalCenter; default: return NULL; } } bool checkInfo(const DAnchorInfo *info1, const DAnchorInfo *info2) const { const Qt::AnchorPoint &p = info2->type; switch (info1->type) { case Qt::AnchorTop://Deliberate case Qt::AnchorBottom://Deliberate case Qt::AnchorVerticalCenter: return (p == Qt::AnchorTop || p == Qt::AnchorBottom || p == Qt::AnchorVerticalCenter); case Qt::AnchorLeft://Deliberate case Qt::AnchorRight://Deliberate case Qt::AnchorHorizontalCenter: return (p == Qt::AnchorLeft || p == Qt::AnchorRight || p == Qt::AnchorHorizontalCenter); default: return false; } } bool isBindable(const DAnchorInfo *info) const { if (fill->target() || centerIn->target()) { return false; } Q_Q(const DAnchorsBase); bool tmp1 = ((int)q->isBinding(top) + (int)q->isBinding(verticalCenter) + (int)q->isBinding(bottom)) < 2; bool tmp2 = ((int)q->isBinding(left) + (int)q->isBinding(horizontalCenter) + (int)q->isBinding(right)) < 2; switch (info->type) { case Qt::AnchorTop://Deliberate case Qt::AnchorBottom://Deliberate case Qt::AnchorHorizontalCenter: return tmp1; case Qt::AnchorLeft://Deliberate case Qt::AnchorRight://Deliberate case Qt::AnchorVerticalCenter: return tmp2; default: return false; } } qreal getValueByInfo(const DAnchorInfo *info) { DAnchorsRect rect = info->base->target()->geometry(); switch (info->type) { case Qt::AnchorTop: return rect.top(); case Qt::AnchorBottom: return rect.bottom() + 1; case Qt::AnchorHorizontalCenter: return rect.horizontalCenter(); case Qt::AnchorLeft: return rect.left(); case Qt::AnchorRight: return rect.right() + 1; case Qt::AnchorVerticalCenter: return rect.verticalCenter(); default: return 0; } } void setValueByInfo(qreal value, const DAnchorInfo *info) { if (!info) { return; } switch (info->type) { case Qt::AnchorTop: info->base->setTop(value, Qt::AnchorTop); break; case Qt::AnchorBottom: info->base->setBottom(value - 1, Qt::AnchorTop); break; case Qt::AnchorHorizontalCenter: info->base->setHorizontalCenter(value, Qt::AnchorLeft); break; case Qt::AnchorLeft: info->base->setLeft(value, Qt::AnchorRight); break; case Qt::AnchorRight: info->base->setRight(value - 1, Qt::AnchorLeft); break; case Qt::AnchorVerticalCenter: info->base->setVerticalCenter(value, Qt::AnchorLeft); break; default: break; } } qreal getTargetValueByInfo(const DAnchorInfo *info) { if (!info->targetInfo) { return getValueByInfo(info); } qreal value = getValueByInfo(info->targetInfo); bool isParent = info->base->target()->parentWidget() == info->targetInfo->base->target(); int topValue = isParent ? -info->targetInfo->base->target()->geometry().top() : 0; int leftValue = isParent ? -info->targetInfo->base->target()->geometry().left() : 0; switch (info->type) { case Qt::AnchorTop: { int offset = topMargin == 0 ? margins : topMargin; return value + offset + topValue; } case Qt::AnchorBottom: { int offset = bottomMargin == 0 ? margins : bottomMargin; return value - offset + topValue - 1; } case Qt::AnchorHorizontalCenter: { int offset = horizontalCenterOffset; return value + offset + leftValue; } case Qt::AnchorLeft: { int offset = leftMargin == 0 ? margins : leftMargin; return value + offset + leftValue; } case Qt::AnchorRight: { int offset = rightMargin == 0 ? margins : rightMargin; return value - offset + leftValue - 1; } case Qt::AnchorVerticalCenter: { int offset = verticalCenterOffset; return value + offset + topValue; } default: return 0; } } const DAnchorsRect getWidgetRect(const QWidget *w) const { if (!w) { return DAnchorsRect(); } if (extendWidget && extendWidget->target()->parentWidget() == w) { return w->rect(); } return w->geometry(); } int horizontalAnchorCount() const { Q_Q(const DAnchorsBase); int count = 0; if(q->isBinding(left)) ++count; if(q->isBinding(horizontalCenter)) ++count; if(q->isBinding(right)) ++count; return count; } int verticalAnchorCount() const { Q_Q(const DAnchorsBase); int count = 0; if(q->isBinding(top)) ++count; if(q->isBinding(verticalCenter)) ++count; if(q->isBinding(bottom)) ++count; return count; } DAnchorsBase *q_ptr; QPointer extendWidget; DAnchorInfo *top = new DAnchorInfo(q_ptr, Qt::AnchorTop); DAnchorInfo *bottom = new DAnchorInfo(q_ptr, Qt::AnchorBottom); DAnchorInfo *left = new DAnchorInfo(q_ptr, Qt::AnchorLeft); DAnchorInfo *right = new DAnchorInfo(q_ptr, Qt::AnchorRight); DAnchorInfo *horizontalCenter = new DAnchorInfo(q_ptr, Qt::AnchorHorizontalCenter); DAnchorInfo *verticalCenter = new DAnchorInfo(q_ptr, Qt::AnchorVerticalCenter); DEnhancedWidget *fill = new DEnhancedWidget(NULL, q_ptr); DEnhancedWidget *centerIn = new DEnhancedWidget(NULL, q_ptr); int margins = 0; int topMargin = 0; int bottomMargin = 0; int leftMargin = 0; int rightMargin = 0; int horizontalCenterOffset = 0; int verticalCenterOffset = 0; bool alignWhenCentered = false; DAnchorsBase::AnchorError errorCode = DAnchorsBase::NoError; QString errorString; static QMap widgetMap; Q_DECLARE_PUBLIC(DAnchorsBase) }; QMap DAnchorsBasePrivate::widgetMap; DAnchorsBase::DAnchorsBase(QWidget *w): QObject(w) { init(w); } DAnchorsBase::~DAnchorsBase() { DAnchorsBasePrivate::removeWidgetAnchorsBase(target(), this); } QWidget *DAnchorsBase::target() const { Q_D(const DAnchorsBase); if (!d->extendWidget) return 0; return d->extendWidget->target(); } DEnhancedWidget *DAnchorsBase::enhancedWidget() const { Q_D(const DAnchorsBase); return d->extendWidget; } bool DAnchorsBase::enabled() const { Q_D(const DAnchorsBase); if (!d->extendWidget) return false; return d->extendWidget->enabled(); } const DAnchorsBase *DAnchorsBase::anchors() const { return this; } const DAnchorInfo *DAnchorsBase::top() const { Q_D(const DAnchorsBase); return d->top; } const DAnchorInfo *DAnchorsBase::bottom() const { Q_D(const DAnchorsBase); return d->bottom; } const DAnchorInfo *DAnchorsBase::left() const { Q_D(const DAnchorsBase); return d->left; } const DAnchorInfo *DAnchorsBase::right() const { Q_D(const DAnchorsBase); return d->right; } const DAnchorInfo *DAnchorsBase::horizontalCenter() const { Q_D(const DAnchorsBase); return d->horizontalCenter; } const DAnchorInfo *DAnchorsBase::verticalCenter() const { Q_D(const DAnchorsBase); return d->verticalCenter; } QWidget *DAnchorsBase::fill() const { Q_D(const DAnchorsBase); if (d->fill) { return d->fill->target(); } return NULL; } QWidget *DAnchorsBase::centerIn() const { Q_D(const DAnchorsBase); if (d->centerIn) { return d->centerIn->target(); } return NULL; } int DAnchorsBase::margins() const { Q_D(const DAnchorsBase); return d->margins; } int DAnchorsBase::topMargin() const { Q_D(const DAnchorsBase); return d->topMargin; } int DAnchorsBase::bottomMargin() const { Q_D(const DAnchorsBase); return d->bottomMargin; } int DAnchorsBase::leftMargin() const { Q_D(const DAnchorsBase); return d->leftMargin; } int DAnchorsBase::rightMargin() const { Q_D(const DAnchorsBase); return d->rightMargin; } int DAnchorsBase::horizontalCenterOffset() const { Q_D(const DAnchorsBase); return d->horizontalCenterOffset; } int DAnchorsBase::verticalCenterOffset() const { Q_D(const DAnchorsBase); return d->verticalCenterOffset; } int DAnchorsBase::alignWhenCentered() const { Q_D(const DAnchorsBase); return d->alignWhenCentered; } DAnchorsBase::AnchorError DAnchorsBase::errorCode() const { Q_D(const DAnchorsBase); return d->errorCode; } QString DAnchorsBase::errorString() const { Q_D(const DAnchorsBase); return d->errorString; } bool DAnchorsBase::isBinding(const DAnchorInfo *info) const { return info->targetInfo; } bool DAnchorsBase::setAnchor(QWidget *w, const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point) { if (!w || !target) { return false; } DAnchorsBase *base = DAnchorsBasePrivate::getWidgetAnchorsBase(w); if (!base) { base = new DAnchorsBase(w); } return base->setAnchor(p, target, point); } void DAnchorsBase::clearAnchors(const QWidget *w) { DAnchorsBase *base = DAnchorsBasePrivate::getWidgetAnchorsBase(w); if (base) { delete base; } } DAnchorsBase *DAnchorsBase::getAnchorBaseByWidget(const QWidget *w) { return DAnchorsBasePrivate::getWidgetAnchorsBase(w); } void DAnchorsBase::setEnabled(bool enabled) { Q_D(DAnchorsBase); if (!d->extendWidget) return; d->extendWidget->setEnabled(enabled); } bool DAnchorsBase::setAnchor(const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point) { if (!target) { return false; } DAnchorsBase *base = DAnchorsBasePrivate::getWidgetAnchorsBase(target); if (!base) { base = new DAnchorsBase(target); } const DAnchorInfo *info = base->d_func()->getInfoByPoint(point); switch (p) { case Qt::AnchorTop: return setTop(info); case Qt::AnchorBottom: return setBottom(info); case Qt::AnchorLeft: return setLeft(info); case Qt::AnchorRight: return setRight(info); case Qt::AnchorHorizontalCenter: return setHorizontalCenter(info); case Qt::AnchorVerticalCenter: return setVerticalCenter(info); default: return false; } } #define ANCHOR_BIND_INFO(point, Point, slotName, ...)\ Q_D(DAnchorsBase);\ if(*d->point == point)\ return true;\ DEnhancedWidget *tmp_w1 = NULL;\ DEnhancedWidget *tmp_w2 = NULL;\ if(d->point->targetInfo){\ tmp_w1 = d->point->targetInfo->base->d_func()->extendWidget;\ }\ QStringList signalList = QString(#__VA_ARGS__).split("),");\ if(point){\ if(!d->isBindable(d->point)){\ d->errorCode = Conflict;\ d->errorString = "Conflict: CenterIn or Fill is anchored.";\ return false;\ }\ if (point->base == d->q_func()){\ d->errorCode = TargetInvalid;\ d->errorString = "Cannot anchor widget to self.";\ return false;\ }else if(target()->parentWidget() != point->base->target()){\ bool isBrother = false;\ Q_FOREACH (const QWidget *w, target()->parentWidget()->findChildren()) {\ if(w == point->base->target()){\ isBrother = true;\ break;\ }\ }\ if(!isBrother){\ d->errorCode = TargetInvalid;\ d->errorString = "Cannot anchor to an widget that isn't a parent or sibling.";\ return false;\ }\ }\ if(!d->checkInfo(d->point, point)){\ d->errorCode = PointInvalid;\ d->errorString = "Cannot anchor a vertical/horizontal edge to a horizontal/vertical edge.";\ return false;\ }\ int old_pos = d->getValueByInfo(point);\ DAnchorInfo old_info = *d->point;\ *d->point = point;\ slotName();\ if(old_pos != d->getValueByInfo(point)){\ *d->point = old_info;\ slotName();\ d->errorCode = PointInvalid;\ d->errorString = "loop bind.";\ return false;\ }else{\ old_pos = d->getValueByInfo(d->point);\ int target_old_value = d->getValueByInfo(point);\ /*保存widget当然的一些标志位,setValueByInfo仅仅是尝试设置,调用之后要复原标志位*/\ bool moved = point->base->target()->testAttribute(Qt::WA_Moved);\ bool resized = point->base->target()->testAttribute(Qt::WA_Resized);\ d->setValueByInfo(target_old_value + 1, point);\ if(old_pos != d->getValueByInfo(d->point)){\ *d->point = old_info;\ slotName();\ d->setValueByInfo(target_old_value, point);\ point->base->target()->setAttribute(Qt::WA_Moved, moved);\ point->base->target()->setAttribute(Qt::WA_Resized, resized);\ d->errorCode = PointInvalid;\ d->errorString = "loop bind.";\ return false;\ }\ d->setValueByInfo(target_old_value, point);\ point->base->target()->setAttribute(Qt::WA_Moved, moved);\ point->base->target()->setAttribute(Qt::WA_Resized, resized);\ }\ tmp_w2 = point->base->d_func()->extendWidget;\ if(tmp_w1 != tmp_w2){\ Q_FOREACH(QString str, signalList){\ QByteArray arr = str.replace(" ", "").toLatin1();\ if(arr.right(1) != ")") arr += ")";\ if(tmp_w1) {\ disconnect(tmp_w1, QByteArray("2"+arr).data(), d->q_func(), SLOT(slotName()));\ disconnect(tmp_w1, SIGNAL(showed()), d->q_func(), SLOT(slotName()));\ }\ if(arr.size() != 13 || target()->parentWidget() != point->base->target()) {\ connect(tmp_w2, QByteArray("2"+arr).data(), d->q_func(), SLOT(slotName()));\ connect(tmp_w2, SIGNAL(showed()), d->q_func(), SLOT(slotName()));\ }\ }\ }\ }else{\ Q_FOREACH(QString str, signalList){\ QByteArray arr = str.replace(" ", "").toLatin1();\ if(arr.right(1) != ")") arr += ")";\ disconnect(tmp_w1, QByteArray("2"+arr).data(), d->q_func(), SLOT(slotName()));\ disconnect(tmp_w1, SIGNAL(showed()), d->q_func(), SLOT(slotName()));\ }\ *d->point = point;\ }\ if((isBinding(d->right) || isBinding(d->horizontalCenter)) && d->horizontalAnchorCount() == 1)\ {connect(d->extendWidget, SIGNAL(widthChanged(int)), d->q_func(), SLOT(updateHorizontal()));}\ else disconnect(d->extendWidget, SIGNAL(widthChanged(int)), d->q_func(), SLOT(updateHorizontal()));\ if((isBinding(d->bottom) || isBinding(d->verticalCenter)) && d->verticalAnchorCount() == 1)\ {connect(d->extendWidget, SIGNAL(heightChanged(int)), d->q_func(), SLOT(updateVertical()));}\ else disconnect(d->extendWidget, SIGNAL(heightChanged(int)), d->q_func(), SLOT(updateVertical()));\ Q_EMIT point##Changed(d->point);\ return true;\ #define ANCHOR_BIND_WIDGET(point, Point)\ if(d->point->target() == point)\ return true;\ if(point){\ if (point == target()){\ d->errorCode = TargetInvalid;\ d->errorString = "Cannot anchor widget to self.";\ return false;\ }else if(target()->parentWidget() != point){\ bool isBrother = false;\ Q_FOREACH (const QWidget *w, target()->parentWidget()->findChildren()) {\ if(w == point){\ isBrother = true;\ break;\ }\ }\ if(!isBrother){\ d->errorCode = TargetInvalid;\ d->errorString = "Cannot anchor to an widget that isn't a parent or sibling.";\ return false;\ }\ }\ QRect old_rect = point->geometry();\ QWidget *old_widget = d->point->target();\ d->point->setTarget(point);\ update##Point();\ if(old_rect != point->geometry()){\ d->point->setTarget(old_widget);\ update##Point();\ d->errorCode = PointInvalid;\ d->errorString = "loop bind.";\ return false;\ }\ DAnchorInfo *info = NULL;\ setTop(info);setLeft(info);setRight(info);setBottom(info);setHorizontalCenter(info);setVerticalCenter(info);setCenterIn((QWidget*)NULL);\ if(d->point == d->fill)\ setCenterIn((QWidget*)NULL);\ if(target()->parentWidget() == point)\ disconnect(d->point, SIGNAL(positionChanged(QPoint)), d->q_func(), SLOT(update##Point()));\ else connect(d->point, SIGNAL(positionChanged(QPoint)), d->q_func(), SLOT(update##Point()));\ }\ d->point->setTarget(point);\ if(d->centerIn){connect(d->extendWidget, SIGNAL(sizeChanged(QSize)), d->q_func(), SLOT(updateCenterIn()));}\ else disconnect(d->extendWidget, SIGNAL(sizeChanged(QSize)), d->q_func(), SLOT(updateCenterIn()));\ Q_EMIT point##Changed(point);\ return true;\ bool DAnchorsBase::setTop(const DAnchorInfo *top) { ANCHOR_BIND_INFO(top, Top, updateVertical , yChanged(int), heightChanged(int)) } bool DAnchorsBase::setBottom(const DAnchorInfo *bottom) { ANCHOR_BIND_INFO(bottom, Bottom, updateVertical , yChanged(int), heightChanged(int)) } bool DAnchorsBase::setLeft(const DAnchorInfo *left) { ANCHOR_BIND_INFO(left, Left, updateHorizontal, xChanged(int), widthChanged(int)) } bool DAnchorsBase::setRight(const DAnchorInfo *right) { ANCHOR_BIND_INFO(right, Right, updateHorizontal, xChanged(int), widthChanged(int)) } bool DAnchorsBase::setHorizontalCenter(const DAnchorInfo *horizontalCenter) { ANCHOR_BIND_INFO(horizontalCenter, HorizontalCenter, updateHorizontal, xChanged(int), widthChanged(int)) } bool DAnchorsBase::setVerticalCenter(const DAnchorInfo *verticalCenter) { ANCHOR_BIND_INFO(verticalCenter, VerticalCenter, updateVertical , yChanged(int), heightChanged(int)) } bool DAnchorsBase::setFill(QWidget *fill) { Q_D(DAnchorsBase); ANCHOR_BIND_WIDGET(fill, Fill) } bool DAnchorsBase::setCenterIn(QWidget *centerIn) { Q_D(DAnchorsBase); if (centerIn && d->fill->target()) { d->errorCode = Conflict; d->errorString = "Conflict: Fill is anchored."; return false; } ANCHOR_BIND_WIDGET(centerIn, CenterIn) } bool DAnchorsBase::setFill(DAnchorsBase *fill) { return setFill(fill->target()); } bool DAnchorsBase::setCenterIn(DAnchorsBase *centerIn) { return setCenterIn(centerIn->target()); } void DAnchorsBase::setMargins(int margins) { Q_D(DAnchorsBase); if (d->margins == margins) { return; } d->margins = margins; if (margins != 0) { if (d->fill->target()) { updateFill(); } else { updateVertical(); updateHorizontal(); } } Q_EMIT marginsChanged(margins); } void DAnchorsBase::setTopMargin(int topMargin) { Q_D(DAnchorsBase); if (d->topMargin == topMargin) { return; } d->topMargin = topMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->top)) { updateVertical(); } Q_EMIT topMarginChanged(topMargin); } void DAnchorsBase::setBottomMargin(int bottomMargin) { Q_D(DAnchorsBase); if (d->bottomMargin == bottomMargin) { return; } d->bottomMargin = bottomMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->bottom)) { updateVertical(); } Q_EMIT bottomMarginChanged(bottomMargin); } void DAnchorsBase::setLeftMargin(int leftMargin) { Q_D(DAnchorsBase); if (d->leftMargin == leftMargin) { return; } d->leftMargin = leftMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->left)) { updateHorizontal(); } Q_EMIT leftMarginChanged(leftMargin); } void DAnchorsBase::setRightMargin(int rightMargin) { Q_D(DAnchorsBase); if (d->rightMargin == rightMargin) { return; } d->rightMargin = rightMargin; if (isBinding(d->right)) { updateHorizontal(); } if (d->fill->target()) { updateFill(); } Q_EMIT rightMarginChanged(rightMargin); } void DAnchorsBase::setHorizontalCenterOffset(int horizontalCenterOffset) { Q_D(DAnchorsBase); if (d->horizontalCenterOffset == horizontalCenterOffset) { return; } d->horizontalCenterOffset = horizontalCenterOffset; if (isBinding(d->horizontalCenter)) { updateHorizontal(); } Q_EMIT horizontalCenterOffsetChanged(horizontalCenterOffset); } void DAnchorsBase::setVerticalCenterOffset(int verticalCenterOffset) { Q_D(DAnchorsBase); if (d->verticalCenterOffset == verticalCenterOffset) { return; } d->verticalCenterOffset = verticalCenterOffset; if (isBinding(d->verticalCenter)) { updateVertical(); } Q_EMIT verticalCenterOffsetChanged(verticalCenterOffset); } void DAnchorsBase::setAlignWhenCentered(bool alignWhenCentered) { Q_D(DAnchorsBase); if (d->alignWhenCentered == alignWhenCentered) { return; } d->alignWhenCentered = alignWhenCentered; Q_EMIT alignWhenCenteredChanged(alignWhenCentered); } #define SET_POS(fun)\ DAnchorsRect rect = target()->geometry();\ rect.set##fun(arg, point);\ target()->setMinimumSize(QSize(0,0));\ target()->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));\ target()->setGeometry(rect); #define MOVE_POS(fun)\ DAnchorsRect rect = target()->geometry();\ rect.move##fun(arg);\ target()->move(rect.topLeft()); void DAnchorsBase::setTop(int arg, Qt::AnchorPoint point) { SET_POS(Top) } void DAnchorsBase::setBottom(int arg, Qt::AnchorPoint point) { SET_POS(Bottom) } void DAnchorsBase::setLeft(int arg, Qt::AnchorPoint point) { SET_POS(Left) } void DAnchorsBase::setHorizontalCenter(int arg, Qt::AnchorPoint point) { SET_POS(HorizontalCenter) } void DAnchorsBase::setVerticalCenter(int arg, Qt::AnchorPoint point) { SET_POS(VerticalCenter) } void DAnchorsBase::setRight(int arg, Qt::AnchorPoint point) { SET_POS(Right) } void DAnchorsBase::moveTop(int arg) { MOVE_POS(Top) } void DAnchorsBase::moveBottom(int arg) { MOVE_POS(Bottom) } void DAnchorsBase::moveLeft(int arg) { MOVE_POS(Left) } void DAnchorsBase::moveRight(int arg) { MOVE_POS(Right) } void DAnchorsBase::moveHorizontalCenter(int arg) { MOVE_POS(HorizontalCenter) } void DAnchorsBase::moveVerticalCenter(int arg) { MOVE_POS(VerticalCenter) } void DAnchorsBase::moveCenter(const QPoint &arg) { MOVE_POS(Center) } #define UPDATE_GEOMETRY(p1,P1,p2,P2,p3,P3)\ Q_D(DAnchorsBase);\ if(isBinding(d->p1)){\ int p1##Value = d->getTargetValueByInfo(d->p1);\ move##P1(p1##Value);\ if(isBinding(d->p2)){\ qreal value = d->getTargetValueByInfo(d->p2);\ set##P3(2 * value - p1##Value, Qt::Anchor##P1);\ }else if(isBinding(d->p3)){\ set##P3(d->getTargetValueByInfo(d->p3), Qt::Anchor##P1);\ }\ }else if(isBinding(d->p3)){\ int p3##Value = d->getTargetValueByInfo(d->p3);\ move##P3(p3##Value);\ if(isBinding(d->p2)){\ qreal value = d->getTargetValueByInfo(d->p2);\ set##P1(2 * value - p3##Value, Qt::Anchor##P1);\ }\ }else if(isBinding(d->p2)){\ move##P2(d->getTargetValueByInfo(d->p2));\ }\ void DAnchorsBase::updateVertical() { UPDATE_GEOMETRY(top, Top, verticalCenter, VerticalCenter, bottom, Bottom) } void DAnchorsBase::updateHorizontal() { UPDATE_GEOMETRY(left, Left, horizontalCenter, HorizontalCenter, right, Right) } void DAnchorsBase::updateFill() { Q_D(DAnchorsBase); QRect rect = d->getWidgetRect(d->fill->target()); int offset = d->topMargin != 0 ? d->topMargin : d->margins; rect.setTop(rect.top() + offset); offset = d->bottomMargin != 0 ? d->bottomMargin : d->margins; rect.setBottom(rect.bottom() - offset); offset = d->leftMargin != 0 ? d->leftMargin : d->margins; rect.setLeft(rect.left() + offset); offset = d->rightMargin != 0 ? d->rightMargin : d->margins; rect.setRight(rect.right() - offset); target()->setFixedSize(rect.size()); target()->move(rect.topLeft()); } void DAnchorsBase::updateCenterIn() { Q_D(DAnchorsBase); QRect rect = d->getWidgetRect(d->centerIn->target()); moveCenter(rect.center()); } void DAnchorsBase::init(QWidget *w) { Q_D(DAnchorsBase); DAnchorsBase *base = DAnchorsBasePrivate::getWidgetAnchorsBase(w); if (base) { d_ptr = base->d_ptr; } else if (d && d->q_func() == this) { d->removeWidgetAnchorsBase(target(), this); d->setWidgetAnchorsBase(w, this); d->extendWidget->setTarget(w); } else { base = new DAnchorsBase(w, false); d_ptr = base->d_ptr; } } DAnchorsBase::DAnchorsBase(QWidget *w, bool): QObject(w), d_ptr(new DAnchorsBasePrivate(this)) { Q_D(DAnchorsBase); d->extendWidget = new DEnhancedWidget(w, this); connect(d->extendWidget, SIGNAL(enabledChanged(bool)), SIGNAL(enabledChanged(bool))); connect(d->fill, SIGNAL(sizeChanged(QSize)), SLOT(updateFill())); connect(d->centerIn, SIGNAL(sizeChanged(QSize)), SLOT(updateCenterIn())); connect(d->fill, SIGNAL(showed()), SLOT(updateFill())); connect(d->centerIn, SIGNAL(showed()), SLOT(updateCenterIn())); d->setWidgetAnchorsBase(w, this); } void DAnchorsRect::setTop(int arg, Qt::AnchorPoint point) { if (point == Qt::AnchorVerticalCenter) { QRect::setBottom(bottom() + arg - top()); } QRect::setTop(arg); } void DAnchorsRect::setVerticalCenter(qreal arg, Qt::AnchorPoint point) { if (point == Qt::AnchorTop) { QRect::setBottom(2 * arg - top()); } else if (point == Qt::AnchorBottom) { QRect::setTop(2 * arg - bottom()); } } void DAnchorsRect::setBottom(int arg, Qt::AnchorPoint point) { if (point == Qt::AnchorVerticalCenter) { setHeight(arg - bottom()); } QRect::setBottom(arg); } void DAnchorsRect::setLeft(int arg, Qt::AnchorPoint point) { if (point == Qt::AnchorHorizontalCenter) { setWidth(left() - arg); } QRect::setLeft(arg); } void DAnchorsRect::setHorizontalCenter(qreal arg, Qt::AnchorPoint point) { if (point == Qt::AnchorLeft) { QRect::setRight(2 * arg - left()); } else if (point == Qt::AnchorRight) { QRect::setLeft(2 * arg - right()); } } void DAnchorsRect::setRight(int arg, Qt::AnchorPoint point) { if (point == Qt::AnchorHorizontalCenter) { setWidth(arg - right()); } QRect::setRight(arg); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/danchors.h000066400000000000000000000205321325435343100200620ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd. * * Author: kirigaya * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DANCHORS_H #define DANCHORS_H #include #include #include #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DAnchorsBase; struct DAnchorInfo { DAnchorInfo(DAnchorsBase *b, const Qt::AnchorPoint &t): base(b), type(t) { } DAnchorsBase *base; Qt::AnchorPoint type; const DAnchorInfo *targetInfo = NULL; bool operator==(const DAnchorInfo *info) const { return info == targetInfo; } bool operator==(const DAnchorInfo &info) const { return &info == targetInfo; } bool operator!=(const DAnchorInfo *info) const { return info != targetInfo; } bool operator!=(const DAnchorInfo &info) const { return &info != targetInfo; } const DAnchorInfo &operator=(const DAnchorInfo *info) { targetInfo = info; return *this; } }; class DAnchorsBasePrivate; class DEnhancedWidget; class DAnchorsBase : public QObject { Q_OBJECT Q_PROPERTY(QWidget *target READ target CONSTANT) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(const DAnchorsBase *anchors READ anchors) Q_PROPERTY(const DAnchorInfo *top READ top WRITE setTop NOTIFY topChanged) Q_PROPERTY(const DAnchorInfo *bottom READ bottom WRITE setBottom NOTIFY bottomChanged) Q_PROPERTY(const DAnchorInfo *left READ left WRITE setLeft NOTIFY leftChanged) Q_PROPERTY(const DAnchorInfo *right READ right WRITE setRight NOTIFY rightChanged) Q_PROPERTY(const DAnchorInfo *horizontalCenter READ horizontalCenter WRITE setHorizontalCenter NOTIFY horizontalCenterChanged) Q_PROPERTY(const DAnchorInfo *verticalCenter READ verticalCenter WRITE setVerticalCenter NOTIFY verticalCenterChanged) Q_PROPERTY(QWidget *fill READ fill WRITE setFill NOTIFY fillChanged) Q_PROPERTY(QWidget *centerIn READ centerIn WRITE setCenterIn NOTIFY centerInChanged) Q_PROPERTY(int margins READ margins WRITE setMargins NOTIFY marginsChanged) Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) Q_PROPERTY(int horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged) Q_PROPERTY(int verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged) Q_PROPERTY(bool alignWhenCentered READ alignWhenCentered WRITE setAlignWhenCentered NOTIFY alignWhenCenteredChanged) public: explicit DAnchorsBase(QWidget *w); ~DAnchorsBase(); enum AnchorError { NoError, Conflict, TargetInvalid, PointInvalid, LoopBind }; QWidget *target() const; DEnhancedWidget *enhancedWidget() const; bool enabled() const; const DAnchorsBase *anchors() const; const DAnchorInfo *top() const; const DAnchorInfo *bottom() const; const DAnchorInfo *left() const; const DAnchorInfo *right() const; const DAnchorInfo *horizontalCenter() const; const DAnchorInfo *verticalCenter() const; QWidget *fill() const; QWidget *centerIn() const; int margins() const; int topMargin() const; int bottomMargin() const; int leftMargin() const; int rightMargin() const; int horizontalCenterOffset() const; int verticalCenterOffset() const; int alignWhenCentered() const; AnchorError errorCode() const; QString errorString() const; bool isBinding(const DAnchorInfo *info) const; static bool setAnchor(QWidget *w, const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point); static void clearAnchors(const QWidget *w); static DAnchorsBase *getAnchorBaseByWidget(const QWidget *w); public Q_SLOTS: void setEnabled(bool enabled); bool setAnchor(const Qt::AnchorPoint &p, QWidget *target, const Qt::AnchorPoint &point); bool setTop(const DAnchorInfo *top); bool setBottom(const DAnchorInfo *bottom); bool setLeft(const DAnchorInfo *left); bool setRight(const DAnchorInfo *right); bool setHorizontalCenter(const DAnchorInfo *horizontalCenter); bool setVerticalCenter(const DAnchorInfo *verticalCenter); bool setFill(QWidget *fill); bool setCenterIn(QWidget *centerIn); bool setFill(DAnchorsBase *fill); bool setCenterIn(DAnchorsBase *centerIn); void setMargins(int margins); void setTopMargin(int topMargin); void setBottomMargin(int bottomMargin); void setLeftMargin(int leftMargin); void setRightMargin(int rightMargin); void setHorizontalCenterOffset(int horizontalCenterOffset); void setVerticalCenterOffset(int verticalCenterOffset); void setAlignWhenCentered(bool alignWhenCentered); void setTop(int arg, Qt::AnchorPoint point); void setBottom(int arg, Qt::AnchorPoint point); void setLeft(int arg, Qt::AnchorPoint point); void setRight(int arg, Qt::AnchorPoint point); void setHorizontalCenter(int arg, Qt::AnchorPoint point); void setVerticalCenter(int arg, Qt::AnchorPoint point); void moveTop(int arg); void moveBottom(int arg); void moveLeft(int arg); void moveRight(int arg); void moveHorizontalCenter(int arg); void moveVerticalCenter(int arg); void moveCenter(const QPoint &arg); private Q_SLOTS: void updateVertical(); void updateHorizontal(); void updateFill(); void updateCenterIn(); Q_SIGNALS: void enabledChanged(bool enabled); void topChanged(const DAnchorInfo *top); void bottomChanged(const DAnchorInfo *bottom); void leftChanged(const DAnchorInfo *left); void rightChanged(const DAnchorInfo *right); void horizontalCenterChanged(const DAnchorInfo *horizontalCenter); void verticalCenterChanged(const DAnchorInfo *verticalCenter); void fillChanged(QWidget *fill); void centerInChanged(QWidget *centerIn); void marginsChanged(int margins); void topMarginChanged(int topMargin); void bottomMarginChanged(int bottomMargin); void leftMarginChanged(int leftMargin); void rightMarginChanged(int rightMargin); void horizontalCenterOffsetChanged(int horizontalCenterOffset); void verticalCenterOffsetChanged(int verticalCenterOffset); void alignWhenCenteredChanged(bool alignWhenCentered); protected: void init(QWidget *w); private: DAnchorsBase(QWidget *w, bool); QExplicitlySharedDataPointer d_ptr; Q_DECLARE_PRIVATE(DAnchorsBase) }; template class DAnchors : public DAnchorsBase { public: inline DAnchors(): DAnchorsBase((QWidget*)NULL), m_widget(NULL) {} inline DAnchors(T *w): DAnchorsBase(w), m_widget(w) {} inline DAnchors(const DAnchors &me): DAnchorsBase(me.m_widget), m_widget(me.m_widget) {} inline T &operator=(const DAnchors &me) { m_widget = me.m_widget; init(m_widget); return *m_widget; } inline T &operator=(T *w) { m_widget = w; init(w); return *m_widget; } inline T *widget() const { return m_widget; } inline T *operator ->() const { return m_widget; } inline T &operator *() const { return *m_widget; } inline operator T *() const { return m_widget; } inline operator T &() const { return *m_widget; } private: T *m_widget; }; DWIDGET_END_NAMESPACE #endif // DANCHORS_H dtkwidget-2.0.7.2/src/widgets/dapplication.cpp000066400000000000000000000543141325435343100212700ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #ifdef Q_OS_LINUX #ifdef private #undef private #endif #define private public #include #undef private #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef Q_OS_UNIX #include #endif #include "dapplication.h" #include "dthememanager.h" #include "private/dapplication_p.h" #include "daboutdialog.h" #ifdef Q_OS_UNIX #include #include #include #include #include #endif #ifdef Q_OS_LINUX #include "startupnotificationmonitor.h" #endif #define DXCB_PLUGIN_KEY "dxcb" #define DXCB_PLUGIN_SYMBOLIC_PROPERTY "_d_isDxcb" DCORE_USE_NAMESPACE DWIDGET_BEGIN_NAMESPACE DApplicationPrivate::DApplicationPrivate(DApplication *q) : DObjectPrivate(q) { #ifdef Q_OS_LINUX StartupNotificationMonitor *monitor = StartupNotificationMonitor::instance(); QObject::connect(monitor, &StartupNotificationMonitor::appStartup, [this, q](const QString id) { m_monitoredStartupApps.append(id); q->setOverrideCursor(Qt::WaitCursor); }); QObject::connect(monitor, &StartupNotificationMonitor::appStartupCompleted, [this, q](const QString id) { m_monitoredStartupApps.removeAll(id); if (m_monitoredStartupApps.isEmpty()) { q->setOverrideCursor(Qt::ArrowCursor); } }); #endif } DApplicationPrivate::~DApplicationPrivate() { if (m_localServer) { m_localServer->close(); } } QString DApplicationPrivate::theme() const { return DThemeManager::instance()->theme(); } void DApplicationPrivate::setTheme(const QString &theme) { DThemeManager *themeManager = DThemeManager::instance(); themeManager->setTheme(theme); } static bool tryAcquireSystemSemaphore(QSystemSemaphore *ss, qint64 timeout = 10) { if (ss->error() != QSystemSemaphore::NoError) { return false; } QSystemSemaphore _tmp_ss(QString("%1-%2").arg("DTK::tryAcquireSystemSemaphore").arg(ss->key()), 1, QSystemSemaphore::Open); _tmp_ss.acquire(); QElapsedTimer t; QFuture request = QtConcurrent::run(ss, &QSystemSemaphore::acquire); t.start(); while (Q_LIKELY(t.elapsed() < timeout && !request.isFinished())); if (request.isFinished()) { return true; } if (Q_LIKELY(request.isRunning())) { if (Q_LIKELY(ss->release(1))) { request.waitForFinished(); } } return false; } bool DApplicationPrivate::setSingleInstanceBySemaphore(const QString &key) { static QSystemSemaphore ss(key, 1, QSystemSemaphore::Open); static bool singleInstance = false; if (singleInstance) { return true; } Q_ASSERT_X(ss.error() == QSystemSemaphore::NoError, "DApplicationPrivate::setSingleInstanceBySemaphore:", ss.errorString().toLocal8Bit().constData()); singleInstance = tryAcquireSystemSemaphore(&ss); if (singleInstance) { QtConcurrent::run([] { while (ss.acquire() && singleInstance) { if (qApp->startingUp() || qApp->closingDown()) { break; } ss.release(1); Q_EMIT qApp->newInstanceStarted(); } }); auto clean_fun = [] { ss.release(1); singleInstance = false; }; qAddPostRoutine(clean_fun); atexit(clean_fun); } return singleInstance; } #ifdef Q_OS_UNIX /** * \brief DApplicationPrivate::setSingleInstanceByDbus will check singleinstance by * register dbus service * \param key is the last of dbus service name, like "com.deepin.SingleInstance.key" * \return */ bool DApplicationPrivate::setSingleInstanceByDbus(const QString &key) { auto basename = "com.deepin.SingleInstance."; QString name = basename + key; auto sessionBus = QDBusConnection::sessionBus(); if (!sessionBus.registerService(name)) { qDebug() << "register service failed:" << sessionBus.lastError(); return false; } return true; } #endif bool DApplicationPrivate::loadDtkTranslator(QList localeFallback) { D_Q(DApplication); auto qtTranslator = new QTranslator(q); qtTranslator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); q->installTranslator(qtTranslator); auto qtbaseTranslator = new QTranslator(q); qtTranslator->load("qtbase_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); q->installTranslator(qtbaseTranslator); QList translateDirs; auto dtkwidgetDir = "dtkwidget"; auto dtkwidgetName = "dtkwidget2"; //("/home/user/.local/share", "/usr/local/share", "/usr/share") auto dataDirs = DStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); for (const auto &path : dataDirs) { DPathBuf DPathBuf(path); translateDirs << DPathBuf / dtkwidgetDir / "translations"; } DPathBuf runDir(q->applicationDirPath()); translateDirs << runDir.join("translations"); DPathBuf currentDir(QDir::currentPath()); translateDirs << currentDir.join("translations"); return loadTranslator(translateDirs, dtkwidgetName, localeFallback); } bool DApplicationPrivate::loadTranslator(QList translateDirs, const QString &name, QList localeFallback) { D_Q(DApplication); for (auto &locale : localeFallback) { QString translateFilename = QString("%1_%2").arg(name).arg(locale.name()); for (auto &path : translateDirs) { QString translatePath = (path / translateFilename).toString(); if (QFile::exists(translatePath + ".qm")) { qDebug() << "load translate" << translatePath; auto translator = new QTranslator(q); translator->load(translatePath); q->installTranslator(translator); return true; } } QStringList parseLocalNameList = locale.name().split("_", QString::SkipEmptyParts); if (parseLocalNameList.length() > 0) { translateFilename = QString("%1_%2").arg(name) .arg(parseLocalNameList.at(0)); for (auto &path : translateDirs) { QString translatePath = (path / translateFilename).toString(); if (QFile::exists(translatePath + ".qm")) { qDebug() << "translatePath after feedback:" << translatePath; auto translator = new QTranslator(q); translator->load(translatePath); q->installTranslator(translator); return true; } } } } qWarning() << name << "can not find qm files" ; return false; } bool DApplicationPrivate::isUserManualExists() { #ifdef Q_OS_LINUX QDBusInterface manualSearch("com.deepin.Manual.Search", "/com/deepin/Manual/Search", "com.deepin.Manual.Search"); if (manualSearch.isValid()) { QDBusReply reply = manualSearch.call("ManualExists", qApp->applicationName()); return reply.value(); } else { const QString appName = qApp->applicationName(); bool dmanAppExists = QFile::exists("/usr/bin/dman"); bool dmanDataExists = QFile::exists("/usr/share/dman/" + appName) || QFile::exists("/app/share/dman/" + appName); return dmanAppExists && dmanDataExists; } #else return false; #endif } /** * @brief DApplication::DApplication constructs an instance of DApplication. * @param argc is the same as in the main function. * @param argv is the same as in the main function. */ DApplication::DApplication(int &argc, char **argv) : QApplication(argc, argv), DObject(*new DApplicationPrivate(this)) { qputenv("QT_QPA_PLATFORM", QByteArray()); QPixmapCache::setCacheLimit(0); } /** * @brief DApplication::theme returns name of the theme that the application is currently using. * * theme name can be one of light, dark, semidark or semilight. * * @return the theme name. */ QString DApplication::theme() const { D_DC(DApplication); return d->theme(); } /** * @brief DApplication::setTheme for the application to use the theme we provide. * @param theme is the name of the theme we want to set. */ void DApplication::setTheme(const QString &theme) { D_D(DApplication); d->setTheme(theme); } /** * @brief DApplication::setSingleInstance marks this application to be single instanced. * @param key is used as the unique ID of every application. * * It should be in form of dde-dock, dde-desktop or dde-control-center etc. * * You can use dbus implement if you use an sandbox like flatpak and so on, just * build with DTK_DBUS_SINGLEINSTANCE * * @return true if succeed, otherwise false. */ bool DApplication::setSingleInstance(const QString &key) { return setSingleInstance(key, SystemScope); } bool DApplication::setSingleInstance(const QString &key, SingleScope singleScope) { D_D(DApplication); QString k = key; #ifdef Q_OS_UNIX switch (singleScope) { case DApplication::UserScope: k += QString("_%1").arg(getuid()); break; default: break; } #endif #ifdef Q_OS_UNIX if (qgetenv("DTK_USE_DBUS_SINGLEINSTANCE") == "TRUE") { return d->setSingleInstanceByDbus(k); } #endif return d->setSingleInstanceBySemaphore(k); } //! load translate file form system or application data path; /*! \param localeFallback, a list of fallback locale you want load. \return load success */ bool DApplication::loadTranslator(QList localeFallback) { D_D(DApplication); d->loadDtkTranslator(localeFallback); QList translateDirs; auto appName = applicationName(); //("/home/user/.local/share", "/usr/local/share", "/usr/share") auto dataDirs = DStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); for (const auto &path : dataDirs) { DPathBuf DPathBuf(path); translateDirs << DPathBuf / appName / "translations"; } DPathBuf runDir(this->applicationDirPath()); translateDirs << runDir.join("translations"); DPathBuf currentDir(QDir::currentPath()); translateDirs << currentDir.join("translations"); return d->loadTranslator(translateDirs, appName, localeFallback); } bool DApplication::loadDXcbPlugin() { Q_ASSERT_X(!qApp, "DApplication::loadDxcbPlugin", "Must call before QGuiApplication defined object"); if (!QPlatformIntegrationFactory::keys().contains(DXCB_PLUGIN_KEY)) { return false; } // fix QGuiApplication::platformName() to xcb qputenv("DXCB_FAKE_PLATFORM_NAME_XCB", "true"); return qputenv("QT_QPA_PLATFORM", DXCB_PLUGIN_KEY); } bool DApplication::isDXcbPlatform() { return qApp && (qApp->platformName() == DXCB_PLUGIN_KEY || qApp->property(DXCB_PLUGIN_SYMBOLIC_PROPERTY).toBool()); } int DApplication::buildDtkVersion() { return DtkBuildVersion::value; } int DApplication::runtimeDtkVersion() { return DTK_VERSION; } /** * @brief DApplication::productName returns the product name of this application. * * It's mainly used to construct an about dialog of the application. * * @return the product name of this application if set, otherwise the applicationDisplayName. */ QString DApplication::productName() const { D_DC(DApplication); return d->productName.isEmpty() ? applicationDisplayName() : d->productName; } /** * @brief DApplication::setProductName sets the product name of this application. * @param productName is the product name to be set. */ void DApplication::setProductName(const QString &productName) { D_D(DApplication); d->productName = productName; } /** * @brief DApplication::productIcon returns the product icon of this application. * * It's mainly used to construct an about dialog of the application. * * @return the product icon of this application if set, otherwise empty. */ const QIcon &DApplication::productIcon() const { D_DC(DApplication); return d->productIcon; } /** * @brief DApplication::setProductIcon sets the product icon of this application. * @param productIcon is the product icon to be set. */ void DApplication::setProductIcon(const QPixmap &productIconPixmap) { D_D(DApplication); d->productIcon = productIconPixmap; } /** * @brief DApplication::setProductIcon sets the product icon of this application. * @param productIcon is the product icon to be set. */ void DApplication::setProductIcon(const QIcon &productIcon) { D_D(DApplication); d->productIcon = productIcon; } /** * @brief DApplication::applicationLicense returns the license used by this application. * * It's mainly used to construct an about dialog of the application. * * @return the license used by this application. */ QString DApplication::applicationLicense() const { D_DC(DApplication); return d->appLicense; } /** * @brief DApplication::setApplicationLicense sets the license of this application. * @param license is the license to be set. */ void DApplication::setApplicationLicense(const QString &license) { D_D(DApplication); d->appLicense = license; } /** * @brief DApplication::applicationDescription returns the long description of the application. * * It's mainly used to construct an about dialog of the application. * * @return the description of the application if set, otherwise empty. */ QString DApplication::applicationDescription() const { D_DC(DApplication); return d->appDescription; } /** * @brief DApplication::setApplicationDescription sets the description of the application. * @param description is description to be set. */ void DApplication::setApplicationDescription(const QString &description) { D_D(DApplication); d->appDescription = description; } QString DApplication::applicationHomePage() const { D_DC(DApplication); return d->homePage; } void DApplication::setApplicationHomePage(const QString &link) { D_D(DApplication); d->homePage = link; } /** * @brief DApplication::applicationAcknowledgementPage returns the acknowlegement page of the application. * * It's mainly used to construct an about dialog of the application. * * @return the acknowlegement page of the application if set, otherwise empty. */ QString DApplication::applicationAcknowledgementPage() const { D_DC(DApplication); return d->acknowledgementPage; } /** * @brief DApplication::setApplicationAcknowledgementPage sets the acknowlegement page of the application. * @param link is the acknowlegement page link to be shown in the about dialog. */ void DApplication::setApplicationAcknowledgementPage(const QString &link) { D_D(DApplication); d->acknowledgementPage = link; } /** * @brief DApplication::aboutDialog returns the about dialog of this application. * * If the about dialog is not set, it will automatically construct one. * * @return the about dialog instance. */ DAboutDialog *DApplication::aboutDialog() { D_D(DApplication); return d->aboutDialog; } /** * @brief DApplication::setAboutDialog sets the about dialog of this application. * * It's mainly used to override the auto-constructed about dialog which is not * a common case, so please do double check before using this method. * * @param aboutDialog */ void DApplication::setAboutDialog(DAboutDialog *aboutDialog) { D_D(DApplication); if (d->aboutDialog && d->aboutDialog != aboutDialog) { d->aboutDialog->deleteLater(); } d->aboutDialog = aboutDialog; } bool DApplication::visibleMenuShortcutText() const { D_DC(DApplication); return d->visibleMenuShortcutText; } void DApplication::setVisibleMenuShortcutText(bool value) { D_D(DApplication); d->visibleMenuShortcutText = value; } bool DApplication::visibleMenuCheckboxWidget() const { D_DC(DApplication); return d->visibleMenuCheckboxWidget; } void DApplication::setVisibleMenuCheckboxWidget(bool value) { D_D(DApplication); d->visibleMenuCheckboxWidget = value; } bool DApplication::visibleMenuIcon() const { D_DC(DApplication); return d->visibleMenuIcon; } void DApplication::setVisibleMenuIcon(bool value) { D_D(DApplication); d->visibleMenuIcon = value; } /** * @brief DApplication::helpActionHandler * * Triggered when user clicked the help menu item of this window's titlebar, * default action is to open the user manual of this program, override this * method if you want to change the default action. * */ void DApplication::handleHelpAction() { #ifdef Q_OS_LINUX QString appid = applicationName(); // new interface use applicationName as id QDBusInterface manual("com.deepin.Manual.Open", "/com/deepin/Manual/Open", "com.deepin.Manual.Open"); if (manual.isValid()) { manual.asyncCall("ShowManual", appid); return; } // fallback to old interface if (!qgetenv("FLATPAK_APPID").isEmpty()) { appid = qgetenv("FLATPAK_APPID"); QDBusInterface legacydman("com.deepin.dman", "/com/deepin/dman", "com.deepin.dman"); if (legacydman.isValid()) { // will block application legacydman.call("ShowManual", appid); return; } qWarning() << "can not call dman dbus interface"; } else { QProcess::startDetached("dman", QStringList() << appid); } #else qWarning() << "not support dman now"; #endif } /** * @brief DApplication::aboutActionHandler * * Triggered when user clicked the about menu item of this window's titlebar, * default action is to show the about dialog of this window(if there is one), * override this method if you want to change the default action. * */ void DApplication::handleAboutAction() { D_D(DApplication); if (d->aboutDialog) { d->aboutDialog->show(); return; } DAboutDialog *aboutDialog = new DAboutDialog(activeWindow()); aboutDialog->setProductName(productName()); aboutDialog->setProductIcon(productIcon()); aboutDialog->setVersion(translate("DAboutDialog", "Version: %1").arg(applicationVersion())); aboutDialog->setDescription(applicationDescription()); if (!applicationLicense().isEmpty()) { aboutDialog->setLicense(translate("DAboutDialog", "%1 is released under %2").arg(productName()).arg(applicationLicense())); } if (!applicationAcknowledgementPage().isEmpty()) { aboutDialog->setAcknowledgementLink(applicationAcknowledgementPage()); } aboutDialog->exec(); aboutDialog->deleteLater(); } /** * @brief DApplication::quitActionHandler * * Triggered when user clicked the exit menu item of this window's titlebar, * default action is to quit this program, you can try to save your data before * the program quitting by connecting to the aboutToQuit signal of this application. * override this method if you want to change the default action. * */ void DApplication::handleQuitAction() { quit(); } static inline bool basePrintPropertiesDialog(const QWidget *w) { while (w) { if (w->inherits("QPrintPropertiesDialog") || w->inherits("QPageSetupDialog")) { return true; } w = w->parentWidget(); } return false; } bool DApplication::notify(QObject *obj, QEvent *event) { if (event->type() == QEvent::PolishRequest) { // Fixed the style for the menu widget to dlight // ugly code will no longer needed. static QStyle *light_style = nullptr; if (QMenu *menu = qobject_cast(obj)) { if (!menu->testAttribute(Qt::WA_SetStyle)) { if (!light_style) { light_style = QStyleFactory::create("dlight"); } if (light_style) { menu->setStyle(light_style); } } } #ifdef Q_OS_LINUX else if (QWidget *widget = qobject_cast(obj)) { if (!widget->testAttribute(Qt::WA_SetStyle) && (widget->inherits("QPrintDialog") || widget->inherits("QPrintPropertiesDialog") || widget->inherits("QPageSetupDialog") || widget->inherits("QPrintPreviewDialog") || (widget->inherits("QComboBoxPrivateContainer") && basePrintPropertiesDialog(widget)))) { if (!light_style) { light_style = QStyleFactory::create("dlight"); } if (light_style) { widget->setStyle(light_style); if (widget->style() != light_style) { widget->style()->deleteLater(); widget->d_func()->setStyle_helper(light_style, false); } for (QWidget *w : widget->findChildren()) { w->setStyle(light_style); } } } } #endif } else if (event->type() == QEvent::ParentChange) { if (QWidget *widget = qobject_cast(obj)) { DThemeManager::instance()->updateThemeOnParentChanged(widget); } } return QApplication::notify(obj, event); } int DtkBuildVersion::value = 0; DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dapplication.h000066400000000000000000000110271325435343100207270ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DAPPLICATION_H #define DAPPLICATION_H #include #include "dtkwidget_global.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE #define DAPPLICATION_XSTRING(s) DAPPLICATION_STRING(s) #define DAPPLICATION_STRING(s) #s class DApplication; class DApplicationPrivate; class DAboutDialog; #if defined(qApp) #undef qApp #endif #define qApp (static_cast(QCoreApplication::instance())) class LIBDTKWIDGETSHARED_EXPORT DApplication : public QApplication, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT D_DECLARE_PRIVATE(DApplication) Q_PROPERTY(bool visibleMenuShortcutText READ visibleMenuShortcutText WRITE setVisibleMenuShortcutText) Q_PROPERTY(bool visibleMenuCheckboxWidget READ visibleMenuCheckboxWidget WRITE setVisibleMenuCheckboxWidget) Q_PROPERTY(bool visibleMenuIcon READ visibleMenuIcon WRITE setVisibleMenuIcon) public: DApplication(int &argc, char **argv); enum SingleScope { UserScope, SystemScope }; QString theme() const; void setTheme(const QString &theme); bool setSingleInstance(const QString &key); bool setSingleInstance(const QString &key, SingleScope singleScope); bool loadTranslator(QList localeFallback = QList() << QLocale::system()); //! warning: Must call before QGuiApplication defined object static bool loadDXcbPlugin(); static bool isDXcbPlatform(); // return the libdtkwidget version of build application static int buildDtkVersion(); // return the libdtkwidget version of runing application static int runtimeDtkVersion(); // meta information that necessary to create a about dialog for the application. QString productName() const; void setProductName(const QString &productName); const QIcon &productIcon() const; void D_DECL_DEPRECATED_X("Use void setProductIcon(const QIcon &productIcon).")setProductIcon(const QPixmap &productIconPixmap); void setProductIcon(const QIcon &productIcon); QString applicationLicense() const; void setApplicationLicense(const QString &license); QString applicationDescription() const; void setApplicationDescription(const QString &description); QString applicationHomePage() const; void setApplicationHomePage(const QString &link); QString applicationAcknowledgementPage() const; void setApplicationAcknowledgementPage(const QString &link); DAboutDialog *aboutDialog(); void setAboutDialog(DAboutDialog *aboutDialog); bool visibleMenuShortcutText() const; void setVisibleMenuShortcutText(bool value); bool visibleMenuCheckboxWidget() const; void setVisibleMenuCheckboxWidget(bool value); bool visibleMenuIcon() const; void setVisibleMenuIcon(bool value); #ifdef VERSION static inline QString buildVersion(const QString &fallbackVersion) { QString autoVersion = DAPPLICATION_XSTRING(VERSION); if (autoVersion.isEmpty()) { autoVersion = fallbackVersion; } return autoVersion; } #else static inline QString buildVersion(const QString &fallbackVersion) { return fallbackVersion; } #endif Q_SIGNALS: void newInstanceStarted(); //###(zccrs): Depend the Qt platform theme plugin(from the package: dde-qt5integration) void iconThemeChanged(); protected: virtual void handleHelpAction(); virtual void handleAboutAction(); virtual void handleQuitAction(); bool notify(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; private: friend class DTitlebarPrivate; friend class DMainWindowPrivate; }; class DtkBuildVersion { public: static int value; }; #ifndef LIBDTKWIDGET_LIBRARY class Q_DECL_HIDDEN _DtkBuildVersion { public: _DtkBuildVersion() { DtkBuildVersion::value = DTK_VERSION; } }; static _DtkBuildVersion _dtk_build_version; #endif DWIDGET_END_NAMESPACE #endif // DAPPLICATION_H dtkwidget-2.0.7.2/src/widgets/darrowbutton.cpp000066400000000000000000000116441325435343100213520ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "darrowbutton.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE ArrowButtonIcon::ArrowButtonIcon(QWidget *parent) : QLabel(parent) { setAttribute(Qt::WA_TransparentForMouseEvents); } void ArrowButtonIcon::setArrowDirection(int direction) { m_direction = direction; style()->unpolish(this); style()->polish(this);// force a stylesheet recomputation } void ArrowButtonIcon::setButtonState(int state) { m_buttonState = state; style()->unpolish(this); style()->polish(this);// force a stylesheet recomputation } int ArrowButtonIcon::arrowDirection() const { return m_direction; } int ArrowButtonIcon::buttonState() const { return m_buttonState; } DArrowButton::DArrowButton(QWidget *parent) : QLabel(parent) { DThemeManager::registerWidget(this); setFixedSize(IMAGE_BUTTON_WIDTH, BUTTON_HEIGHT); m_normalLabel = new ArrowButtonIcon(this); m_normalLabel->setObjectName("ArrowButtonIconNormal"); m_normalLabel->setFixedSize(size()); m_normalLabel->move(0, 0); m_hoverLabel = new ArrowButtonIcon(this); m_hoverLabel->setObjectName("ArrowButtonIconHover"); m_hoverLabel->setFixedSize(size()); m_hoverLabel->move(0, 0); m_hoverLabel->setVisible(false); m_pressLabel = new ArrowButtonIcon(this); m_pressLabel->setObjectName("ArrowButtonIconPress"); m_pressLabel->setFixedSize(size()); m_pressLabel->move(0, 0); m_pressLabel->setVisible(false); setArrowDirection(DArrowButton::ArrowDown); } void DArrowButton::setArrowDirection(ArrowDirection direction) { m_arrowDirection = direction; updateIconDirection(direction); } int DArrowButton::arrowDirection() const { return m_arrowDirection; } void DArrowButton::setButtonState(ArrowButtonState state) { m_buttonState = state; updateIconState(state); } int DArrowButton::buttonState() const { return m_buttonState; } void DArrowButton::mousePressEvent(QMouseEvent *event) { Q_UNUSED(event) Q_EMIT mousePress(); m_normalLabel->setVisible(false); m_hoverLabel->setVisible(false); m_pressLabel->setVisible(true); setButtonState(DArrowButton::ArrowStatePress); } void DArrowButton::mouseReleaseEvent(QMouseEvent *event) { Q_UNUSED(event) Q_EMIT mouseRelease(); m_normalLabel->setVisible(true); m_hoverLabel->setVisible(false); m_pressLabel->setVisible(false); setButtonState(DArrowButton::ArrowStateNormal); } void DArrowButton::enterEvent(QEvent *) { Q_EMIT mouseEnter(); } void DArrowButton::leaveEvent(QEvent *) { Q_EMIT mouseLeave(); } void DArrowButton::initButtonState() { // QStateMachine * machine = new QStateMachine(this); // QState * hoverState = new QState(machine); // hoverState->assignProperty(this,"pos",QPoint(0,0)); // QState * hideState = new QState(machine); // hideState->assignProperty(this,"pos",QPoint(0,height())); // machine->setInitialState(hoverState); // QPropertyAnimation *sa = new QPropertyAnimation(this, "pos"); // sa->setDuration(200); // sa->setEasingCurve(QEasingCurve::InSine); // connect(sa,&QPropertyAnimation::finished,this,&Panel::hasShown); // QPropertyAnimation *ha = new QPropertyAnimation(this, "pos"); // ha->setDuration(200); // ha->setEasingCurve(QEasingCurve::InSine); // connect(ha,&QPropertyAnimation::finished,this,&Panel::hasHidden); // QSignalTransition *ts1 = hoverState->addTransition(this,SIGNAL(startHide()), hideState); // ts1->addAnimation(ha); // connect(ts1,&QSignalTransition::triggered,[=](int value = 2){ // m_HSManager->SetState(value); // }); // QSignalTransition *ts2 = hideState->addTransition(this,SIGNAL(startShow()),hoverState); // ts2->addAnimation(sa); // connect(ts2,&QSignalTransition::triggered,[=](int value = 0){ // m_HSManager->SetState(value); // }); // machine->start(); } void DArrowButton::updateIconDirection(ArrowDirection direction) { m_normalLabel->setArrowDirection(direction); m_hoverLabel->setArrowDirection(direction); m_pressLabel->setArrowDirection(direction); } void DArrowButton::updateIconState(ArrowButtonState state) { m_normalLabel->setButtonState(state); m_hoverLabel->setButtonState(state); m_pressLabel->setButtonState(state); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/darrowbutton.h000066400000000000000000000050411325435343100210110ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DARROWBUTTON_H #define DARROWBUTTON_H #include #include #include #include #include #include #include "dtkwidget_global.h" #include "dconstants.h" DWIDGET_BEGIN_NAMESPACE class ArrowButtonIcon : public QLabel { Q_OBJECT Q_PROPERTY(int arrowButtonDirection READ arrowDirection) Q_PROPERTY(int arrowButtonState READ buttonState) public: explicit ArrowButtonIcon(QWidget *parent = 0); void setArrowDirection(int direction); void setButtonState(int state); int arrowDirection() const; int buttonState() const; private: int m_direction; int m_buttonState; }; class LIBDTKWIDGETSHARED_EXPORT DArrowButton : public QLabel { Q_OBJECT public: enum ArrowDirection { ArrowUp, ArrowDown, ArrowLeft, ArrowRight }; enum ArrowButtonState { ArrowStateNormal, ArrowStateHover, ArrowStatePress }; explicit DArrowButton(QWidget *parent = 0); void setArrowDirection(ArrowDirection direction); int arrowDirection() const; int buttonState() const; protected: void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void enterEvent(QEvent *); void leaveEvent(QEvent *); Q_SIGNALS: void mousePress(); void mouseRelease(); void mouseEnter(); void mouseLeave(); private: void initButtonState(); void setButtonState(ArrowButtonState state); void updateIconDirection(ArrowDirection direction); void updateIconState(ArrowButtonState state); private: ArrowButtonIcon *m_normalLabel = NULL; ArrowButtonIcon *m_hoverLabel = NULL; ArrowButtonIcon *m_pressLabel = NULL; ArrowDirection m_arrowDirection = ArrowDown; ArrowButtonState m_buttonState = ArrowStateNormal; }; DWIDGET_END_NAMESPACE #endif // DARROWBUTTON_H dtkwidget-2.0.7.2/src/widgets/darrowlineexpand.cpp000066400000000000000000000047301325435343100221640ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "darrowlineexpand.h" #include "dthememanager.h" #include DWIDGET_BEGIN_NAMESPACE ArrowHeaderLine::ArrowHeaderLine(QWidget *parent) : DHeaderLine(parent) { m_arrowButton = new DArrowButton(this); connect(m_arrowButton, &DArrowButton::mouseRelease, this, &ArrowHeaderLine::mousePress); setContent(m_arrowButton); setFixedHeight(EXPAND_HEADER_HEIGHT); } void ArrowHeaderLine::setExpand(bool value) { if (value) m_arrowButton->setArrowDirection(DArrowButton::ArrowUp); else m_arrowButton->setArrowDirection(DArrowButton::ArrowDown); } void ArrowHeaderLine::mousePressEvent(QMouseEvent *) { Q_EMIT mousePress(); } void ArrowHeaderLine::reverseArrowDirection() { if (m_arrowButton->arrowDirection() == DArrowButton::ArrowUp) m_arrowButton->setArrowDirection(DArrowButton::ArrowDown); else m_arrowButton->setArrowDirection(DArrowButton::ArrowUp); } DArrowLineExpand::DArrowLineExpand(QWidget *parent) : DBaseExpand(parent) { m_headerLine = new ArrowHeaderLine(this); m_headerLine->setExpand(expand()); connect(m_headerLine, &ArrowHeaderLine::mousePress, [=]{ setExpand(!expand()); }); setHeader(m_headerLine); } void DArrowLineExpand::setTitle(const QString &title) { m_headerLine->setTitle(title); } void DArrowLineExpand::setExpand(bool value) { //Header's arrow direction change here m_headerLine->setExpand(value); DBaseExpand::setExpand(value); } DBaseLine *DArrowLineExpand::headerLine() { return m_headerLine; } void DArrowLineExpand::setHeader(QWidget *header) { DBaseExpand::setHeader(header); } void DArrowLineExpand::resizeEvent(QResizeEvent *e) { m_headerLine->setFixedWidth(e->size().width()); DBaseExpand::resizeEvent(e); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/darrowlineexpand.h000066400000000000000000000032241325435343100216260ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DARROWLINEEXPAND_H #define DARROWLINEEXPAND_H #include #include "dtkwidget_global.h" #include "dbaseexpand.h" #include "darrowbutton.h" #include "dbaseline.h" #include "dheaderline.h" DWIDGET_BEGIN_NAMESPACE class ArrowHeaderLine : public DHeaderLine { Q_OBJECT public: ArrowHeaderLine(QWidget *parent = 0); void setExpand(bool value); Q_SIGNALS: void mousePress(); protected: void mousePressEvent(QMouseEvent *); private: void reverseArrowDirection(); DArrowButton *m_arrowButton = NULL; }; class LIBDTKWIDGETSHARED_EXPORT DArrowLineExpand : public DBaseExpand { Q_OBJECT public: explicit DArrowLineExpand(QWidget *parent = 0); void setTitle(const QString &title); void setExpand(bool value); DBaseLine *headerLine(); private: void setHeader(QWidget *header); void resizeEvent(QResizeEvent *e); private: ArrowHeaderLine *m_headerLine = NULL; }; DWIDGET_END_NAMESPACE #endif // DARROWLINEEXPAND_H dtkwidget-2.0.7.2/src/widgets/darrowrectangle.cpp000066400000000000000000000656011325435343100220050ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "darrowrectangle.h" #include "dplatformwindowhandle.h" #include "dapplication.h" #include "private/darrowrectangle_p.h" #ifdef Q_OS_LINUX #include #include #endif #include #include #include DWIDGET_BEGIN_NAMESPACE /*! * \class DArrowRectangle * \brief The DArrowRectangle class provides a widget that has an arrow on one * of its four borders. * * It's usually used as a container of some other widgets, * see DArrowRectangle::setContent() */ /*! * \brief DArrowRectangle::DArrowRectangle constructs an instance of DArrowRectangle. * \param direction is used to initialize the direction of which the arrow * points to. * \param parent is the parent widget the arrow rectangle will be attached to. */ DArrowRectangle::DArrowRectangle(ArrowDirection direction, QWidget *parent) : QWidget(parent), DObject(*new DArrowRectanglePrivate(direction, this)) { D_D(DArrowRectangle); d->init(FloatWindow); } /*! * \brief DArrowRectangle::DArrowRectangle can set DArrowRectangle show as a window or * a widget in parentWidget by floatMode * \param direction * \param floatMode * \param parent */ DArrowRectangle::DArrowRectangle(ArrowDirection direction, FloatMode floatMode, QWidget *parent) : QWidget(parent), DObject(*new DArrowRectanglePrivate(direction, this)) { D_D(DArrowRectangle); d->init(floatMode); } /*! * \brief DArrowRectangle::show shows the widget at the given coordinate. * * \note The coordiate is calculated to be the arrow head's position, so you * don't need to calculate the position yourself. * * \param x is the x coordinate of the arrow head. * \param y is the y coordinate of the arrow head. */ void DArrowRectangle::show(int x, int y) { D_D(DArrowRectangle); d->show(x, y); } /*! * \brief DArrowRectangle::setContent sets the content of the arrow rectangle. * \param content */ void DArrowRectangle::setContent(QWidget *content) { D_D(DArrowRectangle); d->setContent(content); } /*! * \brief DArrowRectangle::getContent * \return the content that the arrow rectangle holds, null if not set. */ QWidget *DArrowRectangle::getContent() const { D_DC(DArrowRectangle); return d->m_content; } /*! * \brief DArrowRectangle::resizeWithContent automatically adjust the rectangle's * size to fit the its content. */ void DArrowRectangle::resizeWithContent() { D_D(DArrowRectangle); d->resizeWithContent(); } /*! * \brief DArrowRectangle::getFixedSize * \return the size of the whole widget. */ QSize DArrowRectangle::getFixedSize() { D_D(DArrowRectangle); if (d->m_content) { qreal delta = (d->m_handle ? 0 : shadowBlurRadius() + d->m_shadowDistance) + margin(); switch (d->m_arrowDirection) { case ArrowLeft: case ArrowRight: return QSize(d->m_content->width() + delta * 2 + d->m_arrowHeight - ((d->floatMode == FloatWidget) ? delta : 0), d->m_content->height() + delta * 2); case ArrowTop: case ArrowBottom: return QSize(d->m_content->width() + delta * 2, d->m_content->height() + delta * 2 + d->m_arrowHeight - ((d->floatMode == FloatWidget) ? delta : 0)); } } return QSize(0, 0); } /*! * \brief DArrowRectangle::move moves the widget to the coordinate that provided, * * Like the rules in DArrowRectangle::show(int x, int y), it moves the widget so * that the arrow head's coordinate matches the one that provided. * * \param x is the x coordinate of the arrow head. * \param y is the y coordinate of the arrow head. * * \see DArrowRectangle::show(int x, int y) */ void DArrowRectangle::move(int x, int y) { D_D(DArrowRectangle); switch (d->m_arrowDirection) { case ArrowLeft: case ArrowRight: d->verticalMove(x, y); break; case ArrowTop: case ArrowBottom: d->horizontalMove(x, y); break; default: QWidget::move(x, y); break; } } // override methods void DArrowRectangle::paintEvent(QPaintEvent *e) { D_D(DArrowRectangle); d->paintEvent(e); } void DArrowRectangle::resizeEvent(QResizeEvent *e) { D_D(DArrowRectangle); d->resizeEvent(e); } bool DArrowRectangle::event(QEvent *e) { switch (e->type()) { case QEvent::WindowDeactivate: Q_EMIT windowDeactivate(); break; default:; } return QWidget::event(e); } const QRect DArrowRectanglePrivate::currentScreenRect(const int x, const int y) { for (QScreen *screen : qApp->screens()) if (screen->geometry().contains(x, y)) { return screen->geometry(); } return QRect(); } /*! * \property DArrowRectangle::shadowYOffset * \brief the offset of the widget and its shadow on y axis. */ qreal DArrowRectangle::shadowYOffset() const { D_DC(DArrowRectangle); return d->m_shadowYOffset; } void DArrowRectangle::setShadowYOffset(const qreal &shadowYOffset) { D_D(DArrowRectangle); d->m_shadowYOffset = shadowYOffset; if (d->m_handle) { d->m_handle->setShadowOffset(QPoint(d->m_shadowXOffset, shadowYOffset)); } } /*! * \property DArrowRectangle::shadowXOffset * \brief the offset of the widget and its shadow on x axis. */ qreal DArrowRectangle::shadowXOffset() const { D_DC(DArrowRectangle); return d->m_shadowXOffset; } void DArrowRectangle::setShadowXOffset(const qreal &shadowXOffset) { D_D(DArrowRectangle); d->m_shadowXOffset = shadowXOffset; if (d->m_handle) { d->m_handle->setShadowOffset(QPoint(shadowXOffset, d->m_shadowYOffset)); } } qreal DArrowRectangle::shadowDistance() const { D_DC(DArrowRectangle); return d->m_shadowDistance; } void DArrowRectangle::setShadowDistance(const qreal &shadowDistance) { D_D(DArrowRectangle); d->m_shadowDistance = shadowDistance; } /*! * \property DArrowRectangle::shadowBlurRadius * \brief This property holds the blur radius of the widget's shadow. */ qreal DArrowRectangle::shadowBlurRadius() const { D_DC(DArrowRectangle); return d->m_shadowBlurRadius; } void DArrowRectangle::setShadowBlurRadius(const qreal &shadowBlurRadius) { D_D(DArrowRectangle); d->m_shadowBlurRadius = shadowBlurRadius; if (d->m_handle) { d->m_handle->setShadowRadius(shadowBlurRadius); } } /*! * \property DArrowRectangle::borderColor * \brief This property holds the border color of this widget. */ QColor DArrowRectangle::borderColor() const { D_DC(DArrowRectangle); return d->m_borderColor; } void DArrowRectangle::setBorderColor(const QColor &borderColor) { D_D(DArrowRectangle); d->m_borderColor = borderColor; if (d->m_handle) { d->m_handle->setBorderColor(borderColor); } } /*! * \property DArrowRectangle::borderWidth * \brief This property holds the border width of this widget. */ int DArrowRectangle::borderWidth() const { D_DC(DArrowRectangle); return d->m_borderWidth; } void DArrowRectangle::setBorderWidth(int borderWidth) { D_D(DArrowRectangle); d->m_borderWidth = borderWidth; if (d->m_handle) { d->m_handle->setBorderWidth(borderWidth); } } /*! * \property DArrowRectangle::backgroundColor * \brief the background color of this rectangle. */ QColor DArrowRectangle::backgroundColor() const { D_DC(DArrowRectangle); return d->m_backgroundColor; } /*! * \property DArrowRectangle::arrowDirection * \brief This property holds the direction of the rectangle's arrow points to. */ DArrowRectangle::ArrowDirection DArrowRectangle::arrowDirection() const { D_DC(DArrowRectangle); return d->m_arrowDirection; } /*! * \brief DArrowRectangle::setBackgroundColor sets the background color of * this widget. * \param backgroundColor is the target background color. */ void DArrowRectangle::setBackgroundColor(const QColor &backgroundColor) { D_D(DArrowRectangle); d->m_backgroundColor = backgroundColor; if (d->m_handle && d->m_backgroundColor.toRgb().alpha() < 255) { if (!d->m_blurBackground) { d->m_blurBackground = new DBlurEffectWidget(this); d->m_blurBackground->setBlendMode(DBlurEffectWidget::BehindWindowBlend); d->m_blurBackground->resize(size()); d->m_blurBackground->lower(); d->m_blurBackground->show(); } d->m_blurBackground->setMaskColor(d->m_backgroundColor); } else { if (d->m_blurBackground) { d->m_blurBackground->hide(); d->m_blurBackground->setParent(0); delete d->m_blurBackground; d->m_blurBackground = Q_NULLPTR; } } } /*! * \brief DArrowRectangle::setBackgroundColor is an overloaded function. * * It sets the background color by modifing the mask color of the * Dtk::Widget::DBlurEffectWidget. * * \param type is the mask color to set. */ void DArrowRectangle::setBackgroundColor(DBlurEffectWidget::MaskColorType type) { D_D(DArrowRectangle); if (d->m_blurBackground) { d->m_blurBackground->setMaskColor(type); } } /*! * \property DArrowRectangle::radius * \brief radius of the rectangle */ int DArrowRectangle::radius() const { D_DC(DArrowRectangle); return d->m_radius; } /*! * \property DArrowRectangle::arrowHeight * \brief height of rectangle's arrow */ int DArrowRectangle::arrowHeight() const { D_DC(DArrowRectangle); return d->m_arrowHeight; } /*! * \property DArrowRectangle::arrowWidth * \brief width of the rectangle's arrow */ int DArrowRectangle::arrowWidth() const { D_DC(DArrowRectangle); return d->m_arrowWidth; } /*! * \property DArrowRectangle::arrowX * \brief the x coordinate of the rectangle's arrow */ int DArrowRectangle::arrowX() const { D_DC(DArrowRectangle); return d->m_arrowX; } /*! * \property DArrowRectangle::arrowY * \brief the y coordinate of the rectangle's arrow */ int DArrowRectangle::arrowY() const { D_DC(DArrowRectangle); return d->m_arrowY; } /*! * \property DArrowRectangle::margin * \brief This property holds the width of the margin * * The margin is the distance between the innermost pixel of the rectangle and the * outermost pixel of its contents. * * The default margin is 0. */ int DArrowRectangle::margin() const { D_DC(DArrowRectangle); return d->m_margin; } void DArrowRectangle::setArrowDirection(ArrowDirection value) { D_D(DArrowRectangle); d->m_arrowDirection = value; } void DArrowRectangle::setWidth(int value) { setFixedWidth(value); } void DArrowRectangle::setHeight(int value) { setFixedHeight(value); } void DArrowRectangle::setRadius(int value) { D_D(DArrowRectangle); d->m_radius = value; } void DArrowRectangle::setArrowHeight(int value) { D_D(DArrowRectangle); d->m_arrowHeight = value; } void DArrowRectangle::setArrowWidth(int value) { D_D(DArrowRectangle); d->m_arrowWidth = value; } void DArrowRectangle::setArrowX(int value) { D_D(DArrowRectangle); d->m_arrowX = value; } void DArrowRectangle::setArrowY(int value) { D_D(DArrowRectangle); d->m_arrowY = value; } void DArrowRectangle::setMargin(int value) { D_D(DArrowRectangle); d->m_margin = value; } QPainterPath DArrowRectanglePrivate::getLeftCornerPath() { D_Q(DArrowRectangle); QRect rect = q->rect(); if (!m_handle) { qreal delta = q->shadowBlurRadius() + m_shadowDistance; rect = rect.marginsRemoved(QMargins((DArrowRectangle::FloatWidget == floatMode) ? 0 : delta, delta, delta, delta)); } QPoint cornerPoint(rect.x(), rect.y() + (m_arrowY > 0 ? m_arrowY : (rect.height() / 2))); QPoint topLeft(rect.x() + m_arrowHeight, rect.y()); QPoint topRight(rect.x() + rect.width(), rect.y()); QPoint bottomRight(rect.x() + rect.width(), rect.y() + rect.height()); QPoint bottomLeft(rect.x() + m_arrowHeight, rect.y() + rect.height()); int radius = m_radius > (rect.height() / 2) ? (rect.height() / 2) : m_radius; if (!radiusEnabled()) { radius = 0; } QPainterPath border; border.moveTo(topLeft.x() + radius, topLeft.y()); border.lineTo(topRight.x() - radius, topRight.y()); border.arcTo(topRight.x() - 2 * radius, topRight.y(), 2 * radius, 2 * radius, 90, -90); border.lineTo(bottomRight.x(), bottomRight.y() - radius); border.arcTo(bottomRight.x() - 2 * radius, bottomRight.y() - 2 * radius, 2 * radius, 2 * radius, 0, -90); border.lineTo(bottomLeft.x() + radius, bottomLeft.y()); border.arcTo(bottomLeft.x(), bottomLeft.y() - 2 * radius, 2 * radius, 2 * radius, -90, -90); border.lineTo(cornerPoint.x() + m_arrowHeight, cornerPoint.y() + m_arrowWidth / 2); border.lineTo(cornerPoint); border.lineTo(cornerPoint.x() + m_arrowHeight, cornerPoint.y() - m_arrowWidth / 2); border.lineTo(topLeft.x(), topLeft.y() + radius); border.arcTo(topLeft.x(), topLeft.y(), 2 * radius, 2 * radius, -180, -90); return border; } QPainterPath DArrowRectanglePrivate::getRightCornerPath() { D_Q(DArrowRectangle); QRect rect = q->rect(); if (!m_handle) { qreal delta = q->shadowBlurRadius() + m_shadowDistance; rect = rect.marginsRemoved(QMargins(delta, delta, (DArrowRectangle::FloatWidget == floatMode) ? 0 : delta, delta)); } QPoint cornerPoint(rect.x() + rect.width(), rect.y() + (m_arrowY > 0 ? m_arrowY : rect.height() / 2)); QPoint topLeft(rect.x(), rect.y()); QPoint topRight(rect.x() + rect.width() - m_arrowHeight, rect.y()); QPoint bottomRight(rect.x() + rect.width() - m_arrowHeight, rect.y() + rect.height()); QPoint bottomLeft(rect.x(), rect.y() + rect.height()); int radius = this->m_radius > (rect.height() / 2) ? rect.height() / 2 : this->m_radius; if (!radiusEnabled()) { radius = 0; } QPainterPath border; border.moveTo(topLeft.x() + radius, topLeft.y()); border.lineTo(topRight.x() - radius, topRight.y()); border.arcTo(topRight.x() - 2 * radius, topRight.y(), 2 * radius, 2 * radius, 90, -90); border.lineTo(cornerPoint.x() - m_arrowHeight, cornerPoint.y() - m_arrowWidth / 2); border.lineTo(cornerPoint); border.lineTo(cornerPoint.x() - m_arrowHeight, cornerPoint.y() + m_arrowWidth / 2); border.lineTo(bottomRight.x(), bottomRight.y() - radius); border.arcTo(bottomRight.x() - 2 * radius, bottomRight.y() - 2 * radius, 2 * radius, 2 * radius, 0, -90); border.lineTo(bottomLeft.x() + radius, bottomLeft.y()); border.arcTo(bottomLeft.x(), bottomLeft.y() - 2 * radius, 2 * radius, 2 * radius, -90, -90); border.lineTo(topLeft.x(), topLeft.y() + radius); border.arcTo(topLeft.x(), topLeft.y(), 2 * radius, 2 * radius, 180, -90); return border; } QPainterPath DArrowRectanglePrivate::getTopCornerPath() { D_Q(DArrowRectangle); QRect rect = q->rect(); if (!m_handle) { qreal delta = q->shadowBlurRadius() + m_shadowDistance; rect = rect.marginsRemoved(QMargins(delta, (DArrowRectangle::FloatWidget == floatMode) ? 0 : delta, delta, delta)); } QPoint cornerPoint(rect.x() + (m_arrowX > 0 ? m_arrowX : rect.width() / 2), rect.y()); QPoint topLeft(rect.x(), rect.y() + m_arrowHeight); QPoint topRight(rect.x() + rect.width(), rect.y() + m_arrowHeight); QPoint bottomRight(rect.x() + rect.width(), rect.y() + rect.height()); QPoint bottomLeft(rect.x(), rect.y() + rect.height()); int radius = this->m_radius > (rect.height() / 2 - m_arrowHeight) ? rect.height() / 2 - m_arrowHeight : this->m_radius; if (!radiusEnabled()) { radius = 0; } QPainterPath border; border.moveTo(topLeft.x() + radius, topLeft.y()); border.lineTo(cornerPoint.x() - m_arrowWidth / 2, cornerPoint.y() + m_arrowHeight); border.lineTo(cornerPoint); border.lineTo(cornerPoint.x() + m_arrowWidth / 2, cornerPoint.y() + m_arrowHeight); border.lineTo(topRight.x() - radius, topRight.y()); border.arcTo(topRight.x() - 2 * radius, topRight.y(), 2 * radius, 2 * radius, 90, -90); border.lineTo(bottomRight.x(), bottomRight.y() - radius); border.arcTo(bottomRight.x() - 2 * radius, bottomRight.y() - 2 * radius, 2 * radius, 2 * radius, 0, -90); border.lineTo(bottomLeft.x() + radius, bottomLeft.y()); border.arcTo(bottomLeft.x(), bottomLeft.y() - 2 * radius, 2 * radius, 2 * radius, - 90, -90); border.lineTo(topLeft.x(), topLeft.y() + radius); border.arcTo(topLeft.x(), topLeft.y(), 2 * radius, 2 * radius, 180, -90); return border; } QPainterPath DArrowRectanglePrivate::getBottomCornerPath() { D_QC(DArrowRectangle); QRect rect = q->rect(); if (!m_handle) { qreal delta = q->shadowBlurRadius() + m_shadowDistance; rect = rect.marginsRemoved(QMargins(delta, delta, delta, (DArrowRectangle::FloatWidget == floatMode) ? 0 : delta)); } QPoint cornerPoint(rect.x() + (m_arrowX > 0 ? m_arrowX : qRound(double(rect.width()) / 2)), rect.y() + rect.height()); QPoint topLeft(rect.x(), rect.y()); QPoint topRight(rect.x() + rect.width(), rect.y()); QPoint bottomRight(rect.x() + rect.width(), rect.y() + rect.height() - m_arrowHeight); QPoint bottomLeft(rect.x(), rect.y() + rect.height() - m_arrowHeight); int radius = this->m_radius > (rect.height() / 2 - m_arrowHeight) ? rect.height() / 2 - m_arrowHeight : this->m_radius; if (!radiusEnabled()) { radius = 0; } QPainterPath border; border.moveTo(topLeft.x() + radius, topLeft.y()); border.lineTo(topRight.x() - radius, topRight.y()); border.arcTo(topRight.x() - 2 * radius, topRight.y(), 2 * radius, 2 * radius, 90, -90); border.lineTo(bottomRight.x(), bottomRight.y() - radius); border.arcTo(bottomRight.x() - 2 * radius, bottomRight.y() - 2 * radius, 2 * radius, 2 * radius, 0, -90); border.lineTo(cornerPoint.x() + m_arrowWidth / 2, cornerPoint.y() - m_arrowHeight); border.lineTo(cornerPoint); border.lineTo(cornerPoint.x() - m_arrowWidth / 2, cornerPoint.y() - m_arrowHeight); border.lineTo(bottomLeft.x() + radius, bottomLeft.y()); border.arcTo(bottomLeft.x(), bottomLeft.y() - 2 * radius, 2 * radius, 2 * radius, -90, -90); border.lineTo(topLeft.x(), topLeft.y() + radius); border.arcTo(topLeft.x(), topLeft.y(), 2 * radius, 2 * radius, 180, -90); return border; } void DArrowRectanglePrivate::verticalMove(int x, int y) { D_Q(DArrowRectangle); const QRect dRect = currentScreenRect(x, y); qreal delta = m_handle ? 0 : (q->shadowBlurRadius() - m_shadowDistance); int lRelativeY = y - dRect.y() - (q->height() - delta) / 2; int rRelativeY = y - dRect.y() + (q->height() - delta) / 2 - dRect.height(); int absoluteY = 0; if (lRelativeY < 0) { //out of screen in top side //arrowY use relative coordinates q->setArrowY(q->height() / 2 - delta + lRelativeY); absoluteY = dRect.y() - delta; } else if (rRelativeY > 0) { //out of screen in bottom side q->setArrowY(q->height() / 2 - delta / 2 + rRelativeY); absoluteY = dRect.y() + dRect.height() - q->height() + delta; } else { q->setArrowY(0); absoluteY = y - q->height() / 2; } switch (m_arrowDirection) { case DArrowRectangle::ArrowLeft: q->QWidget::move(x, absoluteY); break; case DArrowRectangle::ArrowRight: q->QWidget::move(x - q->width(), absoluteY); break; default: break; } } void DArrowRectanglePrivate::horizontalMove(int x, int y) { D_Q(DArrowRectangle); const QRect dRect = currentScreenRect(x, y); qreal delta = m_handle ? 0 : (q->shadowBlurRadius() - m_shadowDistance); int lRelativeX = x - dRect.x() - (q->width() - delta) / 2; int rRelativeX = x - dRect.x() + (q->width() - delta) / 2 - dRect.width(); int absoluteX = 0; if (lRelativeX < 0) { //out of screen in left side //arrowX use relative coordinates q->setArrowX((q->width() - delta) / 2 + lRelativeX); absoluteX = dRect.x() - delta; } else if (rRelativeX > 0) { //out of screen in right side q->setArrowX(q->width() / 2 - delta * 2 + rRelativeX); absoluteX = dRect.x() + dRect.width() - q->width() + delta; } else { q->setArrowX(0); absoluteX = x - (m_arrowX > 0 ? m_arrowX : (q->width() / 2)); } switch (m_arrowDirection) { case DArrowRectangle::ArrowTop: q->QWidget::move(absoluteX, y); break; case DArrowRectangle::ArrowBottom: q->QWidget::move(absoluteX, y - q->height()); break; default: break; } } void DArrowRectanglePrivate::updateClipPath() { D_Q(DArrowRectangle); if (!m_handle) { return; } QPainterPath path; switch (m_arrowDirection) { case DArrowRectangle::ArrowLeft: path = getLeftCornerPath(); break; case DArrowRectangle::ArrowRight: path = getRightCornerPath(); break; case DArrowRectangle::ArrowTop: path = getTopCornerPath(); break; case DArrowRectangle::ArrowBottom: path = getBottomCornerPath(); break; default: path = getRightCornerPath(); } m_handle->setClipPath(path); } bool DArrowRectanglePrivate::radiusEnabled() { if (m_wmHelper && !m_wmHelper->hasComposite()) { return false; } return true; } DArrowRectangle::~DArrowRectangle() { } Dtk::Widget::DArrowRectanglePrivate::DArrowRectanglePrivate(DArrowRectangle::ArrowDirection direction, DArrowRectangle *q) : DObjectPrivate(q), m_arrowDirection(direction) { } void DArrowRectanglePrivate::init(DArrowRectangle::FloatMode mode) { D_Q(DArrowRectangle); floatMode = mode; if (floatMode) { q->setWindowFlags(Qt::Widget); q->setAttribute(Qt::WA_TranslucentBackground); } else { q->setWindowFlags(Qt::FramelessWindowHint | Qt::ToolTip); q->setAttribute(Qt::WA_TranslucentBackground); } if (DApplication::isDXcbPlatform() && (DArrowRectangle::FloatWindow == floatMode)) { m_handle = new DPlatformWindowHandle(q); m_handle->setTranslucentBackground(true); m_blurBackground = new DBlurEffectWidget(q); m_blurBackground->setMaskColor(DBlurEffectWidget::DarkColor); m_blurBackground->setBlendMode(DBlurEffectWidget::BehindWindowBlend); m_wmHelper = DWindowManagerHelper::instance(); q->connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, q, static_cast(&DArrowRectangle::update), Qt::QueuedConnection); } else { DGraphicsGlowEffect *glowEffect = new DGraphicsGlowEffect; glowEffect->setBlurRadius(q->shadowBlurRadius()); glowEffect->setDistance(m_shadowDistance); glowEffect->setXOffset(q->shadowXOffset()); glowEffect->setYOffset(q->shadowYOffset()); q->setGraphicsEffect(glowEffect); m_wmHelper = nullptr; } } void DArrowRectanglePrivate::show(int x, int y) { D_Q(DArrowRectangle); // if show with FloatMode, must has a parent if (DArrowRectangle::FloatWidget == floatMode && !q->parentWidget()) { qCritical() << q << "Must has parentWidget when show in FloatWidget mode"; Q_ASSERT_X(q->parentWidget(), "DArrowRectanglePrivate::show", "Must has parentWidget when show in FloatWidget mode"); } q->resizeWithContent(); m_lastPos = QPoint(x, y); q->move(x, y);//Overload function if (!q->isVisible()) { q->QWidget::show(); q->QWidget::activateWindow(); } q->update(); updateClipPath(); } void DArrowRectanglePrivate::setContent(QWidget *content) { D_Q(DArrowRectangle); if (!content) { return; } m_content = content; m_content->setParent(q); m_content->show(); qreal delta = (m_handle ? 0 : q->shadowBlurRadius() + m_shadowDistance) + q->margin(); q->resizeWithContent(); switch (m_arrowDirection) { case DArrowRectangle::ArrowLeft: m_content->move(m_arrowHeight + ((DArrowRectangle::FloatWidget == floatMode) ? 0 : delta), delta); break; case DArrowRectangle::ArrowRight: m_content->move(delta, delta); break; case DArrowRectangle::ArrowTop: m_content->move(delta, ((DArrowRectangle::FloatWidget == floatMode) ? 0 : delta) + m_arrowHeight); break; case DArrowRectangle::ArrowBottom: m_content->move(delta, delta); break; } q->update(); } void DArrowRectanglePrivate::resizeWithContent() { D_Q(DArrowRectangle); if (m_content.isNull()) { return; } q->setFixedSize(q->getFixedSize()); #ifdef Q_OS_LINUX const qreal ratio = qApp->devicePixelRatio(); if (!m_handle && !floatMode) { XRectangle m_contentXRect; m_contentXRect.x = m_content->pos().x() * ratio; m_contentXRect.y = m_content->pos().y() * ratio; m_contentXRect.width = m_content->width() * ratio; m_contentXRect.height = m_content->height() * ratio; XShapeCombineRectangles(QX11Info::display(), q->winId(), ShapeInput, 0, 0, &m_contentXRect, 1, ShapeSet, YXBanded); } #endif } void DArrowRectanglePrivate::paintEvent(QPaintEvent *e) { D_Q(DArrowRectangle); if (m_blurBackground) { return; } QPainter painter(q); if (m_handle) { painter.fillRect(e->rect(), m_backgroundColor); } else { painter.setRenderHint(QPainter::Antialiasing); QPainterPath border; switch (m_arrowDirection) { case DArrowRectangle::ArrowLeft: border = getLeftCornerPath(); break; case DArrowRectangle::ArrowRight: border = getRightCornerPath(); break; case DArrowRectangle::ArrowTop: border = getTopCornerPath(); break; case DArrowRectangle::ArrowBottom: border = getBottomCornerPath(); break; default: border = getRightCornerPath(); } painter.setClipPath(border); painter.fillPath(border, QBrush(m_backgroundColor)); QPen strokePen; strokePen.setColor(m_borderColor); strokePen.setWidth(m_borderWidth); painter.strokePath(border, strokePen); } } void DArrowRectanglePrivate::resizeEvent(QResizeEvent *e) { D_Q(DArrowRectangle); q->QWidget::resizeEvent(e); if (m_blurBackground) { m_blurBackground->resize(e->size()); } updateClipPath(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/darrowrectangle.h000066400000000000000000000117431325435343100214500ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DARROWRECTANGLE_H #define DARROWRECTANGLE_H #include #include #include #include #include #include #include #include #include #include "dobject.h" #include "dtkwidget_global.h" #include "dthememanager.h" #include "dgraphicsgloweffect.h" #include "dblureffectwidget.h" DWIDGET_BEGIN_NAMESPACE class DPlatformWindowHandle; class DArrowRectanglePrivate; class LIBDTKWIDGETSHARED_EXPORT DArrowRectangle : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_DISABLE_COPY(DArrowRectangle) D_DECLARE_PRIVATE(DArrowRectangle) public: /** * @brief The ArrowDirection enum contains the possible directions that * the DArrowRectangle's arrow may point to. */ enum ArrowDirection { ArrowLeft, /*!< indicates the arrow of this rectangle will point left */ ArrowRight, /*!< indicates the arrow of this rectangle will point right */ ArrowTop, /*!< indicates the arrow of this rectangle will point up */ ArrowBottom /*!< indicates the arrow of this rectangle will point down */ }; /*! * \brief The FloatMode enum decide the WindowType when DArrowRectangle show */ enum FloatMode { FloatWindow, /*!< Window will show a separate window */ FloatWidget, /*!< Widget must by show in the rect of parentWidget*/ }; explicit DArrowRectangle(ArrowDirection direction, QWidget *parent = 0); explicit DArrowRectangle(ArrowDirection direction, FloatMode floatMode, QWidget *parent = 0); ~DArrowRectangle(); Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth) Q_PROPERTY(int radius READ radius WRITE setRadius) Q_PROPERTY(int arrowWidth READ arrowWidth WRITE setArrowWidth) Q_PROPERTY(int arrowHeight READ arrowHeight WRITE setArrowHeight) Q_PROPERTY(int arrowX READ arrowX WRITE setArrowX) Q_PROPERTY(int arrowY READ arrowY WRITE setArrowY) Q_PROPERTY(int margin READ margin WRITE setMargin) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor) Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) Q_PROPERTY(ArrowDirection arrowDirection READ arrowDirection WRITE setArrowDirection) Q_PROPERTY(qreal shadowXOffset READ shadowXOffset WRITE setShadowXOffset) Q_PROPERTY(qreal shadowYOffset READ shadowYOffset WRITE setShadowYOffset) Q_PROPERTY(qreal shadowBlurRadius READ shadowBlurRadius WRITE setShadowBlurRadius) int radius() const; int arrowHeight() const; int arrowWidth() const; int arrowX() const; int arrowY() const; int margin() const; int borderWidth() const; QColor borderColor() const; QColor backgroundColor() const; ArrowDirection arrowDirection() const; void setRadius(int value); void setArrowHeight(int value); void setArrowWidth(int value); void setArrowX(int value); void setArrowY(int value); void setMargin(int value); void setBorderWidth(int borderWidth); void setBorderColor(const QColor &borderColor); void setBackgroundColor(const QColor &backgroundColor); void setBackgroundColor(DBlurEffectWidget::MaskColorType type); void setArrowDirection(ArrowDirection value); void setWidth(int value); void setHeight(int value); virtual void show(int x, int y); void setContent(QWidget *content); QWidget *getContent() const; void resizeWithContent(); void move(int x, int y); QSize getFixedSize(); qreal shadowXOffset() const; qreal shadowYOffset() const; D_DECL_DEPRECATED qreal shadowDistance() const; qreal shadowBlurRadius() const; void setShadowBlurRadius(const qreal &shadowBlurRadius); D_DECL_DEPRECATED void setShadowDistance(const qreal &shadowDistance); void setShadowXOffset(const qreal &shadowXOffset); void setShadowYOffset(const qreal &shadowYOffset); Q_SIGNALS: void windowDeactivate() const; protected: void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; bool event(QEvent *e) Q_DECL_OVERRIDE; }; DWIDGET_END_NAMESPACE #endif // DARROWRECTANGLE_H dtkwidget-2.0.7.2/src/widgets/dbasebutton.cpp000066400000000000000000000050241325435343100211250ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dbasebutton.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DBaseButton * \brief The DBaseButton class provides deepin style QPushButton. * * DBaseButton will be deprecated and removed in the future, please use * QPushButton, together with dstyle Qt style plugin, QPushButton should have * the same visual effect as DBaseButton. */ /*! * \brief DBaseButton::DBaseButton constructs an instance of DBaseButton. * \param parent is passed to QPushButton constructor. */ DBaseButton::DBaseButton(QWidget *parent) : QPushButton(parent) { DThemeManager::registerWidget(this); initInsideFrame(); } /*! * \brief DBaseButton::DBaseButton constructs an instance of DBaseButton. * \param text is passed to QPushButton constructor. * \param parent is passed to QPushButton constructor. */ DBaseButton::DBaseButton(const QString &text, QWidget *parent) : QPushButton(text, parent) { DThemeManager::registerWidget(this); initInsideFrame(); } /*! * \brief DBaseButton::DBaseButton constructs an instance of DBaseButton. * \param icon is passed to QPushButton constructor. * \param text is passed to QPushButton constructor. * \param parent is passed to QPushButton constructor. */ DBaseButton::DBaseButton(const QIcon &icon, const QString &text, QWidget *parent) : QPushButton(icon, text, parent) { DThemeManager::registerWidget(this); initInsideFrame(); } //Bypassing the problem here //qss can't draw box-shadow void DBaseButton::initInsideFrame() { QFrame *insideFrame = new QFrame; insideFrame->raise(); insideFrame->setAttribute(Qt::WA_TransparentForMouseEvents); insideFrame->setObjectName("ButtonInsideFrame"); QHBoxLayout *insideLayout = new QHBoxLayout(this); insideLayout->setContentsMargins(0, 1, 0, 0); insideLayout->addWidget(insideFrame); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dbasebutton.h000066400000000000000000000023371325435343100205760ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBASEBUTTON_H #define DBASEBUTTON_H #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DBaseButton : public QPushButton { Q_OBJECT public: explicit DBaseButton(QWidget * parent = 0); explicit DBaseButton(const QString & text, QWidget * parent = 0); explicit DBaseButton(const QIcon & icon, const QString & text, QWidget * parent = 0); private: void initInsideFrame(); }; DWIDGET_END_NAMESPACE #endif // DBASEBUTTON_H dtkwidget-2.0.7.2/src/widgets/dbaseexpand.cpp000066400000000000000000000120271325435343100210720ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dbaseexpand.h" #include "dthememanager.h" #include "dboxwidget.h" #include DWIDGET_BEGIN_NAMESPACE DBaseExpand::DBaseExpand(QWidget *parent) : QWidget(parent) { DThemeManager::registerWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); m_headerLayout = new QVBoxLayout(); m_headerLayout->setContentsMargins(0, 0, 0, 0); m_headerLayout->setAlignment(Qt::AlignCenter); m_hSeparator = new DSeparatorHorizontal(); m_bottom_separator = new DSeparatorHorizontal; m_bottom_separator->hide(); connect(this, &DBaseExpand::expandChange, m_bottom_separator, &DSeparatorHorizontal::setVisible); m_contentLoader = new ContentLoader(); m_contentLoader->setFixedHeight(0); // default to not expanded. m_boxWidget = new DVBoxWidget; m_contentLayout = m_boxWidget->layout(); QVBoxLayout *layout_contentLoader = new QVBoxLayout(m_contentLoader); layout_contentLoader->setMargin(0); layout_contentLoader->setSpacing(0); layout_contentLoader->addWidget(m_boxWidget); layout_contentLoader->addStretch(); m_animation = new QPropertyAnimation(m_contentLoader, "height"); m_animation->setDuration(200); m_animation->setEasingCurve(QEasingCurve::InSine); connect(m_animation, &QPropertyAnimation::valueChanged, this, [this] { setFixedHeight(sizeHint().height()); }); mainLayout->addLayout(m_headerLayout); mainLayout->addWidget(m_hSeparator); mainLayout->addWidget(m_contentLoader); mainLayout->addWidget(m_bottom_separator); setLayout(mainLayout); connect(m_boxWidget, &DBoxWidget::sizeChanged, this, [this] { if (m_expand) { int endHeight = 0; endHeight = m_boxWidget->height(); m_animation->setStartValue(m_contentLoader->height()); m_animation->setEndValue(endHeight); m_animation->stop(); m_animation->start(); } }); } DBaseExpand::~DBaseExpand() { if (m_headerLayout) { m_headerLayout->deleteLater(); } if (m_contentLayout) { m_contentLayout->deleteLater(); } if (m_contentLoader) { m_contentLoader->deleteLater(); } if (m_animation) { m_animation->deleteLater(); } } void DBaseExpand::setHeader(QWidget *header) { if (!header) { return; } QLayoutItem *child; while ((child = m_headerLayout->takeAt(0)) != 0) { delete child; } m_headerLayout->addWidget(header); m_header = header; } void DBaseExpand::setContent(QWidget *content, Qt::Alignment alignment) { if (!content) { return; } QLayoutItem *child; while ((child = m_contentLayout->takeAt(0)) != 0) { delete child; } m_contentLayout->addWidget(content, 1, alignment); m_contentLayout->addStretch(1); m_content = content; } void DBaseExpand::setHeaderHeight(int height) { if (m_header) { m_header->setFixedHeight(height); } } void DBaseExpand::setExpand(bool value) { if (m_expand == value) { return; } m_expand = value; Q_EMIT expandChange(value); if (value) { m_animation->setStartValue(0); m_animation->setEndValue(m_boxWidget->height()); } else { m_animation->setStartValue(m_boxWidget->height()); m_animation->setEndValue(0); } m_animation->stop(); m_animation->start(); } bool DBaseExpand::expand() const { return m_expand; } void DBaseExpand::setAnimationDuration(int duration) { m_animation->setDuration(duration); } void DBaseExpand::setAnimationEasingCurve(QEasingCurve curve) { m_animation->setEasingCurve(curve); } void DBaseExpand::setSeparatorVisible(bool arg) { m_hSeparator->setVisible(arg); } void DBaseExpand::setExpandedSeparatorVisible(bool arg) { if (arg) { connect(this, &DBaseExpand::expandChange, m_bottom_separator, &DSeparatorHorizontal::setVisible); m_bottom_separator->show(); } else { disconnect(this, &DBaseExpand::expandChange, m_bottom_separator, &DSeparatorHorizontal::setVisible); m_bottom_separator->hide(); } } void DBaseExpand::resizeEvent(QResizeEvent *e) { if (m_content) { m_content->setFixedWidth(e->size().width()); } QWidget::resizeEvent(e); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dbaseexpand.h000066400000000000000000000045031325435343100205370ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBASEEXPAND_H #define DBASEEXPAND_H #include #include #include #include #include "dtkwidget_global.h" #include "dseparatorhorizontal.h" #include "dconstants.h" DWIDGET_BEGIN_NAMESPACE class ContentLoader : public QFrame { Q_OBJECT Q_PROPERTY(int height READ height WRITE setFixedHeight) public: explicit ContentLoader(QWidget *parent = 0) : QFrame(parent){} }; class DBoxWidget; class LIBDTKWIDGETSHARED_EXPORT DBaseExpand : public QWidget { Q_OBJECT public: explicit DBaseExpand(QWidget *parent = 0); ~DBaseExpand(); void setHeader(QWidget *header); void setContent(QWidget *content, Qt::Alignment alignment = Qt::AlignHCenter); inline QWidget *getContent() const {return m_content;} void setHeaderHeight(int height); virtual void setExpand(bool value); bool expand() const; void setAnimationDuration(int duration); void setAnimationEasingCurve(QEasingCurve curve); void setSeparatorVisible(bool arg); void setExpandedSeparatorVisible(bool arg); Q_SIGNALS: void expandChange(bool e); void sizeChanged(QSize s); protected: void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; private: QWidget *m_header = NULL; QWidget *m_content = NULL; DBoxWidget *m_boxWidget = NULL; QVBoxLayout *m_headerLayout = NULL; QBoxLayout *m_contentLayout = NULL; ContentLoader *m_contentLoader = NULL; DSeparatorHorizontal * m_hSeparator = NULL; DSeparatorHorizontal *m_bottom_separator = NULL; QPropertyAnimation *m_animation = NULL; bool m_expand = false; }; DWIDGET_END_NAMESPACE #endif // DBASEEXPAND_H dtkwidget-2.0.7.2/src/widgets/dbaseline.cpp000066400000000000000000000045151325435343100205450ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dbaseline.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE DBaseLine::DBaseLine(QWidget *parent) : QLabel(parent) { DThemeManager::registerWidget(this); this->setFixedHeight(CONTENT_HEADER_HEIGHT); m_leftLayout = new QHBoxLayout(); m_leftLayout->setMargin(0); m_leftLayout->setSpacing(0); m_rightLayout = new QHBoxLayout(); m_rightLayout->setMargin(0); m_rightLayout->setSpacing(0); m_mainLayout = new QHBoxLayout(); m_mainLayout->setContentsMargins(m_leftMargin, 0, m_rightMargin, 0); m_mainLayout->addLayout(m_leftLayout); m_mainLayout->addStretch(); m_mainLayout->addLayout(m_rightLayout); this->setLayout(m_mainLayout); } void DBaseLine::setLeftContent(QWidget *content) { QLayoutItem *child; while ((child = m_leftLayout->takeAt(0)) != 0) { delete child; } m_leftLayout->addWidget(content); } void DBaseLine::setRightContent(QWidget *content) { QLayoutItem *child; while ((child = m_rightLayout->takeAt(0)) != 0) { delete child; } m_rightLayout->addWidget(content); } QBoxLayout *DBaseLine::leftLayout() { return m_leftLayout; } QBoxLayout *DBaseLine::rightLayout() { return m_rightLayout; } void DBaseLine::setLeftMargin(int margin) { m_leftMargin = margin; m_mainLayout->setContentsMargins(m_leftMargin, 0, m_rightMargin, 0); } void DBaseLine::setRightMargin(int margin) { m_rightMargin = margin; m_mainLayout->setContentsMargins(m_leftMargin, 0, m_rightMargin, 0); } int DBaseLine::leftMargin() const { return m_leftMargin; } int DBaseLine::rightMargin() const { return m_rightMargin; } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dbaseline.h000066400000000000000000000030141325435343100202030ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBASELINE_H #define DBASELINE_H #include #include #include #include "dtkwidget_global.h" #include "dconstants.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DBaseLine : public QLabel { Q_OBJECT public: explicit DBaseLine(QWidget *parent = 0); void setLeftContent(QWidget *content); void setRightContent(QWidget *content); QBoxLayout *leftLayout(); QBoxLayout *rightLayout(); void setLeftMargin(int margin); void setRightMargin(int margin); int leftMargin() const; int rightMargin() const; private: QHBoxLayout *m_mainLayout = NULL; QHBoxLayout *m_leftLayout= NULL; QHBoxLayout *m_rightLayout = NULL; int m_leftMargin = HEADER_LEFT_MARGIN; int m_rightMargin = HEADER_RIGHT_MARGIN; }; DWIDGET_END_NAMESPACE #endif // DBASELINE_H dtkwidget-2.0.7.2/src/widgets/dblureffectwidget.cpp000066400000000000000000000413771325435343100223170ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dblureffectwidget.h" #include "private/dblureffectwidget_p.h" #include "dplatformwindowhandle.h" #include "util/dwindowmanagerhelper.h" #include #include #include #include #include #define MASK_COLOR_ALPHA_BLUR_MODE 102 #define MASK_COLOR_ALPHA_DEFAULT 204 QT_BEGIN_NAMESPACE Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); QT_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE QMultiHash DBlurEffectWidgetPrivate::blurEffectWidgetHash; QHash DBlurEffectWidgetPrivate::windowOfBlurEffectHash; DBlurEffectWidgetPrivate::DBlurEffectWidgetPrivate(DBlurEffectWidget *qq) : DObjectPrivate(qq) { } bool DBlurEffectWidgetPrivate::isBehindWindowBlendMode() const { D_QC(DBlurEffectWidget); return blendMode == DBlurEffectWidget::BehindWindowBlend || q->isTopLevel(); } void DBlurEffectWidgetPrivate::addToBlurEffectWidgetHash() { D_QC(DBlurEffectWidget); QWidget *oldTopLevelWidget = windowOfBlurEffectHash.value(q); if (oldTopLevelWidget) { blurEffectWidgetHash.remove(oldTopLevelWidget, q); updateWindowBlurArea(oldTopLevelWidget); } QWidget *topLevelWidget = q->topLevelWidget(); blurEffectWidgetHash.insertMulti(topLevelWidget, q); windowOfBlurEffectHash[q] = topLevelWidget; updateWindowBlurArea(topLevelWidget); } void DBlurEffectWidgetPrivate::removeFromBlurEffectWidgetHash() { D_QC(DBlurEffectWidget); QWidget *topLevelWidget = windowOfBlurEffectHash.value(q); if (!topLevelWidget) { return; } blurEffectWidgetHash.remove(topLevelWidget, q); windowOfBlurEffectHash.remove(q); updateWindowBlurArea(topLevelWidget); } bool DBlurEffectWidgetPrivate::updateWindowBlurArea() { D_QC(DBlurEffectWidget); QWidget *topLevelWidget = windowOfBlurEffectHash.value(q); return topLevelWidget && updateWindowBlurArea(topLevelWidget); } void DBlurEffectWidgetPrivate::setMaskColor(const QColor &color) { maskColor = color; if (isBehindWindowBlendMode()) { maskColor.setAlpha(DWindowManagerHelper::instance()->hasBlurWindow() ? MASK_COLOR_ALPHA_BLUR_MODE : MASK_COLOR_ALPHA_DEFAULT); } } bool DBlurEffectWidgetPrivate::updateWindowBlurArea(QWidget *topLevelWidget) { if (!topLevelWidget->isVisible()) { return false; } QList blurEffectWidgetList = blurEffectWidgetHash.values(topLevelWidget); bool isExistMaskPath = false; Q_FOREACH (const DBlurEffectWidget *w, blurEffectWidgetList) { if (!w->d_func()->maskPath.isEmpty() && w->isVisible()) { isExistMaskPath = true; break; } } bool ok = false; if (isExistMaskPath) { QList pathList; Q_FOREACH (const DBlurEffectWidget *w, blurEffectWidgetList) { if (!w->isVisible()) { continue; } QPainterPath p; QRect r = w->rect(); r.moveTopLeft(w->mapTo(topLevelWidget, r.topLeft())); p.addRoundedRect(r, w->blurRectXRadius(), w->blurRectYRadius()); if (!w->d_func()->maskPath.isEmpty()) { p &= w->d_func()->maskPath.translated(r.topLeft()); } pathList << p; } ok = DPlatformWindowHandle::setWindowBlurAreaByWM(topLevelWidget, pathList); } else { QVector areaList; areaList.reserve(blurEffectWidgetList.size()); Q_FOREACH (const DBlurEffectWidget *w, blurEffectWidgetList) { if (!w->isVisible()) { continue; } QRect r = w->rect(); r.moveTopLeft(w->mapTo(topLevelWidget, r.topLeft())); areaList << dMakeWMBlurArea(r.x(), r.y(), r.width(), r.height(), w->blurRectXRadius(), w->blurRectYRadius()); } ok = DPlatformWindowHandle::setWindowBlurAreaByWM(topLevelWidget, areaList); } if (blurEffectWidgetList.isEmpty()) { blurEffectWidgetHash.remove(topLevelWidget); } return ok; } /*! * \class DBlurEffectWidget * \brief The DBlurEffectWidget class provides widget that backgrounds are blurred and semitranslucent. * * DBlurEffectWidget is QWidget that has blurry background. With different * blend mode set, DBlurEffectWidget can do in-window-blend, which means the * the widget is blended with the widgets between the top level window and the * widget itself, and behind-window-blend, which means the widget is blended with * the scene behind the window (with the help of WM). * * The effect has optional styles can choose from: DBlurEffectWidget::DarkColor, DBlurEffectWidget::LightColor, and * DBlurEffectWidget::CustomColor. Usually the first two are sufficient, you can also choose * CustomColor and set the color you want by setting DBlurEffectWidget::maskColor. * * \note DBlurEffectWidget with BehindWindowBlend mode will become opaque if * WM supports no X11 composite protocol. */ /*! * \brief DBlurEffectWidget::DBlurEffectWidget constructs an instance of DBlurEffectWidget. * \param parent is passed to QWidget constructor. */ DBlurEffectWidget::DBlurEffectWidget(QWidget *parent) : QWidget(parent) , DObject(*new DBlurEffectWidgetPrivate(this)) { setAttribute(Qt::WA_TranslucentBackground); if (!parent) { D_D(DBlurEffectWidget); d->addToBlurEffectWidgetHash(); } QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::windowManagerChanged, this, [this] { D_D(DBlurEffectWidget); d->updateWindowBlurArea(); }); QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, this, [this] { D_D(DBlurEffectWidget); d->setMaskColor(d->maskColor); }); QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasCompositeChanged, this, [this] { D_D(const DBlurEffectWidget); if (d->maskColorType != CustomColor) update(); }); } DBlurEffectWidget::~DBlurEffectWidget() { D_D(DBlurEffectWidget); if (d->isBehindWindowBlendMode()) { d->removeFromBlurEffectWidgetHash(); } } /*! * \property DBlurEffectWidget::radius * \brief This property holds the radius of the blur effect. * * \note This property has no effect with the DBlurEffectWidget::blendMode set * to DBlurEffectWidget::BehindWindowBlend. */ int DBlurEffectWidget::radius() const { D_DC(DBlurEffectWidget); return d->radius; } /*! * \property DBlurEffectWidget::mode * \brief This property holds which blur alghorithm to be used. * * Currently it only supports DBlurEffectWidget::GaussianBlur. */ DBlurEffectWidget::BlurMode DBlurEffectWidget::mode() const { D_DC(DBlurEffectWidget); return d->mode; } /*! * \property DBlurEffectWidget::blendMode * \brief This property holds which mode is used to blend the widget and its background scene. */ DBlurEffectWidget::BlendMode DBlurEffectWidget::blendMode() const { D_DC(DBlurEffectWidget); return d->blendMode; } /*! * \property DBlurEffectWidget::blurRectXRadius * \brief This property holds the xRadius of the effective background. * * The xRadius and yRadius specify the radius of the ellipses defining * the corners of the effective background. * * \see DBlurEffectWidget::blurRectYRadius */ int DBlurEffectWidget::blurRectXRadius() const { D_DC(DBlurEffectWidget); return d->blurRectXRadius; } /*! * \property DBlurEffectWidget::blurRectYRadius * \brief This property holds the yRadius of the effective background. * * The xRadius and yRadius specify the radius of the ellipses defining * the corners of the effective background. * * \see DBlurEffectWidget::blurRectXRadius */ int DBlurEffectWidget::blurRectYRadius() const { D_DC(DBlurEffectWidget); return d->blurRectYRadius; } /*! * \property DBlurEffectWidget::maskColor * \brief This property holds the background color of this widget. * * It returns predefined colors if the DBlurEffectWidget::maskColorType is set * to DBlurEffectWidget::DarkColor or BlurEffectWidget::LightColor, returns * the color set by DBlurEffectWidget::setMaskColor if * DBlurEffectWidget::maskColorType is set to BlurEffectWidget::CustomColor. */ QColor DBlurEffectWidget::maskColor() const { D_DC(DBlurEffectWidget); switch ((int)d->maskColorType) { case DarkColor: { if (!d->isBehindWindowBlendMode()) { return QColor(0, 0, 0, MASK_COLOR_ALPHA_BLUR_MODE); } if (DWindowManagerHelper::instance()->hasComposite()) { return QColor(0, 0, 0, DWindowManagerHelper::instance()->hasBlurWindow() ? MASK_COLOR_ALPHA_BLUR_MODE : MASK_COLOR_ALPHA_DEFAULT); } else { return QColor("#373F47"); } } case LightColor: { if (!d->isBehindWindowBlendMode()) { return QColor(255, 255, 255, MASK_COLOR_ALPHA_BLUR_MODE); } if (DWindowManagerHelper::instance()->hasComposite()) { return QColor(255, 255, 255, DWindowManagerHelper::instance()->hasBlurWindow() ? MASK_COLOR_ALPHA_BLUR_MODE : MASK_COLOR_ALPHA_DEFAULT); } else { return QColor("#FCFCFC"); } } } return d->maskColor; } /*! * \brief DBlurEffectWidget::setMaskPath set custom area as the effective background. * \param path a QPainterPath to be used as the effectvie background. */ void DBlurEffectWidget::setMaskPath(const QPainterPath &path) { D_D(DBlurEffectWidget); if (d->maskPath == path) { return; } d->maskPath = path; update(); } void DBlurEffectWidget::setRadius(int radius) { D_D(DBlurEffectWidget); if (d->radius == radius) { return; } d->radius = radius; d->sourceImage = QImage(); update(); Q_EMIT radiusChanged(radius); } void DBlurEffectWidget::setMode(DBlurEffectWidget::BlurMode mode) { D_D(DBlurEffectWidget); if (d->mode == mode) { return; } d->mode = mode; Q_EMIT modeChanged(mode); } void DBlurEffectWidget::setBlendMode(DBlurEffectWidget::BlendMode blendMode) { D_D(DBlurEffectWidget); if (d->blendMode == blendMode) { return; } if (blendMode == BehindWindowBlend) { d->addToBlurEffectWidgetHash(); } else { if (blendMode == InWindowBlend) { d->maskColor.setAlpha(MASK_COLOR_ALPHA_BLUR_MODE); } if (d->blendMode == BehindWindowBlend) { d->removeFromBlurEffectWidgetHash(); } } d->blendMode = blendMode; update(); Q_EMIT blendModeChanged(blendMode); } void DBlurEffectWidget::setBlurRectXRadius(int blurRectXRadius) { D_D(DBlurEffectWidget); if (d->blurRectXRadius == blurRectXRadius) { return; } d->blurRectXRadius = blurRectXRadius; update(); Q_EMIT blurRectXRadiusChanged(blurRectXRadius); } void DBlurEffectWidget::setBlurRectYRadius(int blurRectYRadius) { D_D(DBlurEffectWidget); if (d->blurRectYRadius == blurRectYRadius) { return; } d->blurRectYRadius = blurRectYRadius; update(); Q_EMIT blurRectYRadiusChanged(blurRectYRadius); } void DBlurEffectWidget::setMaskColor(QColor maskColor) { D_D(DBlurEffectWidget); if (!maskColor.isValid()) { maskColor = Qt::transparent; } if (d->maskColor == maskColor) { return; } d->maskColorType = CustomColor; d->setMaskColor(maskColor); update(); Q_EMIT maskColorChanged(maskColor); } void DBlurEffectWidget::setMaskColor(DBlurEffectWidget::MaskColorType type) { D_D(DBlurEffectWidget); if (d->maskColorType == type) { return; } d->maskColorType = type; update(); } DBlurEffectWidget::DBlurEffectWidget(DBlurEffectWidgetPrivate &dd, QWidget *parent) : QWidget(parent) , DObject(dd) { } inline QRect operator *(const QRect &rect, qreal scale) { return QRect(rect.left() * scale, rect.top() * scale, rect.width() * scale, rect.height() * scale); } void DBlurEffectWidget::paintEvent(QPaintEvent *event) { D_D(DBlurEffectWidget); QPainter pa(this); if (d->blurRectXRadius > 0 || d->blurRectYRadius > 0) { QPainterPath path; path.addRoundedRect(rect(), d->blurRectXRadius, d->blurRectYRadius); pa.setRenderHint(QPainter::Antialiasing); pa.setClipPath(path); } if (!d->maskPath.isEmpty()) { QPainterPath path = pa.clipPath(); if (path.isEmpty()) { path = d->maskPath; } else { path &= d->maskPath; } pa.setClipPath(path); } if (d->isBehindWindowBlendMode()) { pa.setCompositionMode(QPainter::CompositionMode_Source); } else { int radius = d->radius; QPoint point_offset = mapTo(window(), QPoint(0, 0)); const QRect &paintRect = event->rect(); qreal device_pixel_ratio = devicePixelRatioF(); if (d->sourceImage.isNull()) { const QRect &tmp_rect = rect().translated(point_offset).adjusted(-radius, -radius, radius, radius); d->sourceImage = window()->backingStore()->handle()->toImage().copy(tmp_rect * device_pixel_ratio); d->sourceImage = d->sourceImage.scaledToWidth(d->sourceImage.width() / device_pixel_ratio); } else { QPainter pa_image(&d->sourceImage); pa_image.setCompositionMode(QPainter::CompositionMode_Source); for (const QRect &rect : event->region().rects()) { if (device_pixel_ratio > 1) { const QRect &tmp_rect = this->rect().translated(point_offset); const QImage &area = window()->backingStore()->handle()->toImage().copy(tmp_rect * device_pixel_ratio); pa_image.drawImage(rect.topLeft() + QPoint(radius, radius), area.scaledToWidth(area.width() / device_pixel_ratio).copy(rect)); } else { pa_image.drawImage(rect.topLeft() + QPoint(radius, radius), window()->backingStore()->handle()->toImage().copy(rect.translated(point_offset))); } } pa_image.end(); } QImage image = d->sourceImage.copy(paintRect.adjusted(0, 0, 2 * radius, 2 * radius)); QTransform old_transform = pa.transform(); pa.translate(paintRect.topLeft() - QPoint(radius, radius)); qt_blurImage(&pa, image, radius, false, false); pa.setTransform(old_transform); } pa.fillRect(rect(), maskColor()); } void DBlurEffectWidget::moveEvent(QMoveEvent *event) { D_D(DBlurEffectWidget); if (isTopLevel()) { return QWidget::moveEvent(event); } if (d->blendMode == DBlurEffectWidget::InWindowBlend) { d->sourceImage = QImage(); return QWidget::moveEvent(event); } d->updateWindowBlurArea(); QWidget::moveEvent(event); } void DBlurEffectWidget::resizeEvent(QResizeEvent *event) { D_D(DBlurEffectWidget); d->sourceImage = QImage(); if (!d->isBehindWindowBlendMode()) { return QWidget::resizeEvent(event); } d->updateWindowBlurArea(); QWidget::resizeEvent(event); } void DBlurEffectWidget::showEvent(QShowEvent *event) { D_D(DBlurEffectWidget); if (!d->isBehindWindowBlendMode()) { return QWidget::showEvent(event); } d->addToBlurEffectWidgetHash(); QWidget::showEvent(event); } void DBlurEffectWidget::hideEvent(QHideEvent *event) { D_D(DBlurEffectWidget); if (!d->isBehindWindowBlendMode()) { return QWidget::hideEvent(event); } d->removeFromBlurEffectWidgetHash(); QWidget::hideEvent(event); } void DBlurEffectWidget::changeEvent(QEvent *event) { D_D(DBlurEffectWidget); if (!d->isBehindWindowBlendMode()) { return QWidget::changeEvent(event); } if (event->type() == QEvent::ParentAboutToChange) { d->removeFromBlurEffectWidgetHash(); } else if (event->type() == QEvent::ParentChange) { d->addToBlurEffectWidgetHash(); } QWidget::changeEvent(event); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dblureffectwidget.h000066400000000000000000000101601325435343100217460ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBLUREFFECTWIDGET_H #define DBLUREFFECTWIDGET_H #include "dtkwidget_global.h" #include "dobject.h" #include DWIDGET_BEGIN_NAMESPACE class DBlurEffectWidgetPrivate; class LIBDTKWIDGETSHARED_EXPORT DBlurEffectWidget : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT // The "radius" property is only support for InWindowBlend. See property "blendMode" Q_PROPERTY(int radius READ radius WRITE setRadius NOTIFY radiusChanged) Q_PROPERTY(BlurMode mode READ mode WRITE setMode NOTIFY modeChanged) Q_PROPERTY(BlendMode blendMode READ blendMode WRITE setBlendMode NOTIFY blendModeChanged) Q_PROPERTY(int blurRectXRadius READ blurRectXRadius WRITE setBlurRectXRadius NOTIFY blurRectXRadiusChanged) Q_PROPERTY(int blurRectYRadius READ blurRectYRadius WRITE setBlurRectYRadius NOTIFY blurRectYRadiusChanged) // ###(zccrs): The alpha channel of the color is fixed. // The alpha channel is 102 if the DPlatformWindowHandle::hasBlurWindow() is true, otherwise is 204). Q_PROPERTY(QColor maskColor READ maskColor WRITE setMaskColor NOTIFY maskColorChanged) public: // TODO: To support MeanBlur, MedianBlur, BilateralFilter /*! * \brief The BlurMode enum determines which blur algorithm will be used. */ enum BlurMode { GaussianBlur /*!< gaussian blur */ }; Q_ENUMS(BlurMode) /*! * \brief The BlendMode enum controls with which part the widget will be blended with. */ enum BlendMode { InWindowBlend, /*!< blend with the widgets between the window and this widget */ BehindWindowBlend /*!< blend with the pixels behind the window */ }; Q_ENUMS(BlendMode) /*! * \brief The MaskColorType enum contains the possible color used as the background. */ enum MaskColorType { DarkColor, /*!< dark style, predefined dark color is used */ LightColor, /*!< light style, predefined light color is used */ CustomColor /*!< custom color, custom color is used */ }; Q_ENUMS(MaskColorType) explicit DBlurEffectWidget(QWidget *parent = 0); ~DBlurEffectWidget(); int radius() const; BlurMode mode() const; BlendMode blendMode() const; int blurRectXRadius() const; int blurRectYRadius() const; QColor maskColor() const; void setMaskPath(const QPainterPath &path); public Q_SLOTS: void setRadius(int radius); void setMode(BlurMode mode); void setBlendMode(BlendMode blendMode); void setBlurRectXRadius(int blurRectXRadius); void setBlurRectYRadius(int blurRectYRadius); void setMaskColor(QColor maskColor); void setMaskColor(MaskColorType type); Q_SIGNALS: void radiusChanged(int radius); void modeChanged(BlurMode mode); void blendModeChanged(BlendMode blendMode); void blurRectXRadiusChanged(int blurRectXRadius); void blurRectYRadiusChanged(int blurRectYRadius); void maskColorChanged(QColor maskColor); protected: DBlurEffectWidget(DBlurEffectWidgetPrivate &dd, QWidget *parent = 0); void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; void moveEvent(QMoveEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE; void changeEvent(QEvent *event) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DBlurEffectWidget) }; DWIDGET_END_NAMESPACE #endif // DBLUREFFECTWIDGET_H dtkwidget-2.0.7.2/src/widgets/dboxwidget.cpp000066400000000000000000000123371325435343100207600ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "dthememanager.h" #include "dboxwidget.h" #include "private/dboxwidget_p.h" DWIDGET_BEGIN_NAMESPACE /*! \class DBoxWidget \brief The DBoxWidget widget provides a Adaptive child widget size when child widget size changed. */ DBoxWidgetPrivate::DBoxWidgetPrivate(DBoxWidget *qq): DObjectPrivate(qq), layout(new QBoxLayout(QBoxLayout::TopToBottom)) { } void DBoxWidgetPrivate::init() { Q_Q(DBoxWidget); layout->setMargin(0); layout->setSpacing(0); q->setLayout(layout); q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } /*! * \class DBoxWidget * \brief The DBoxWidget class provides widget born with QBoxLayout set. * * Since an widget with QBoxLayout set is very common use case in Qt programming, * yet very tedious, DBoxWidget is built to ease that pain. * * Also, DBoxWidget will calculate the size it needs automatically, so you don't * need to set width for DHBoxWidget or height for DVBoxLayout. * * \see DHBoxWidget and DVBoxWidget */ /*! * \brief DBoxWidget::DBoxWidget constructs an instance of DBoxWidget. * \param direction is the direction used by the internal QBoxLayout. * \param parent is passed to QFrame constructor. */ DBoxWidget::DBoxWidget(QBoxLayout::Direction direction, QWidget *parent): QFrame(parent), DObject(*new DBoxWidgetPrivate(this)) { DThemeManager::registerWidget(this); d_func()->layout->setDirection(direction); d_func()->init(); } /*! * \property DBoxWidget::direction * \brief This property holds the direction of the internal QBoxLayout. */ QBoxLayout::Direction DBoxWidget::direction() const { Q_D(const DBoxWidget); return d->layout->direction(); } /*! * \property DBoxWidget::layout * \brief This property holds the internal layout object. * * This property can be used to get the internal layout, so you can set * some extra properties on the layout to match the custom needs. */ QBoxLayout *DBoxWidget::layout() const { Q_D(const DBoxWidget); return d->layout; } /*! * \brief DBoxWidget::addWidget adds widget to the internal layout. * \param widget is the widget to be added. */ void DBoxWidget::addWidget(QWidget *widget) { layout()->addWidget(widget); } void DBoxWidget::setDirection(QBoxLayout::Direction direction) { Q_D(DBoxWidget); if (d->layout->direction() == direction) return; d->layout->setDirection(direction); Q_EMIT directionChanged(direction); } void DBoxWidget::updateSize(const QSize &size) { if(direction() == QBoxLayout::TopToBottom || QBoxLayout::BottomToTop) { setFixedHeight(size.height()); if(size.width() > minimumWidth()) setMinimumWidth(qMin(size.width(), maximumWidth())); } else { setFixedWidth(size.width()); if(size.height() > minimumHeight()) setMinimumHeight(qMin(size.height(), maximumHeight())); } } bool DBoxWidget::event(QEvent *ee) { Q_D(const DBoxWidget); if(ee->type() == QEvent::LayoutRequest) { if(size() != d->layout->sizeHint()) { updateSize(d->layout->sizeHint()); updateGeometry(); } } else if(ee->type() == QEvent::Resize) { Q_EMIT sizeChanged(size()); } else if(ee->type() == QEvent::ChildAdded) { updateSize(d->layout->sizeHint()); } else if(ee->type() == QEvent::ChildRemoved) { updateSize(d->layout->sizeHint()); } else if(ee->type() == QEvent::Show) { updateSize(d->layout->sizeHint()); } return QWidget::event(ee); } /*! * \brief DBoxWidget::sizeHint reimplemented from QWidget::sizeHint(). * \return the recommended size of this widget. */ QSize DBoxWidget::sizeHint() const { Q_D(const DBoxWidget); return d->layout->sizeHint(); } /*! * \class DHBoxWidget * \brief The DHBoxWidget class is DBoxWidget with DBoxWidget::direction set to * QBoxLayout::LeftToRight. */ /*! * \brief DHBoxWidget::DHBoxWidget constructs an instance of DHBoxWidget. * \param parent is passed to DBoxWidget constructor. */ DHBoxWidget::DHBoxWidget(QWidget *parent): DBoxWidget(QBoxLayout::LeftToRight, parent) { } /*! * \class DVBoxWidget * \brief The DVBoxWidget class is DBoxWidget with DBoxWidget::direction set to * QBoxLayout::TopToBottom. */ /*! * \brief DVBoxWidget::DVBoxWidget constructs an instance of DVBoxWidget. * \param parent is passed to DBoxWidget constructor. */ DVBoxWidget::DVBoxWidget(QWidget *parent): DBoxWidget(QBoxLayout::TopToBottom, parent) { } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dboxwidget.h000066400000000000000000000036041325435343100204220ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBOXWIDGET_H #define DBOXWIDGET_H #include "dtkwidget_global.h" #include #include #include DWIDGET_BEGIN_NAMESPACE class DBoxWidgetPrivate; class DBoxWidget : public QFrame, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QBoxLayout::Direction direction READ direction WRITE setDirection NOTIFY directionChanged) public: explicit DBoxWidget(QBoxLayout::Direction direction, QWidget *parent = 0); QBoxLayout::Direction direction() const; QBoxLayout *layout() const; void addWidget(QWidget *widget); QSize sizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void setDirection(QBoxLayout::Direction direction); Q_SIGNALS: void sizeChanged(QSize size); void directionChanged(QBoxLayout::Direction direction); protected: virtual void updateSize(const QSize &size); bool event(QEvent *ee) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DBoxWidget) }; class DHBoxWidget : public DBoxWidget { Q_OBJECT public: explicit DHBoxWidget(QWidget *parent = 0); }; class DVBoxWidget : public DBoxWidget { Q_OBJECT public: explicit DVBoxWidget(QWidget *parent = 0); }; DWIDGET_END_NAMESPACE #endif // DBOXWIDGET_H dtkwidget-2.0.7.2/src/widgets/dbuttonlist.cpp000066400000000000000000000146021325435343100211700ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dbuttonlist.h" #include "dthememanager.h" #include "dconstants.h" #include #include #include #include #include #include #include #include #include #include IconButton::IconButton(const QString &Icon, const QString &text, QWidget *parent): QPushButton(text, parent), m_icon(Icon), m_text(text) { initIconLabel(); initConnect(); } void IconButton::initConnect(){ connect(this, SIGNAL(toggled(bool)), m_iconLabel, SLOT(setVisible(bool))); } void IconButton::initIconLabel(){ m_iconLabel = new QLabel(this); setIconLeftMargin(20); m_iconLabel->hide(); QImage image(m_icon); m_iconLabel->setPixmap(QPixmap::fromImage(image)); m_iconLabel->setFixedSize(image.size()); } void IconButton::setIconLeftMargin(int leftMargin){ m_iconLabel->move(leftMargin, y()); } void IconButton::resizeEvent(QResizeEvent *event){ int height = event->size().height(); m_iconLabel->move(m_iconLabel->x(), (height - m_iconLabel->height())/ 2 ); QPushButton::resizeEvent(event); } void IconButton::setIconLabel(const QString &icon){ m_icon = icon; QImage image(m_icon); m_iconLabel->setPixmap(QPixmap::fromImage(image)); m_iconLabel->setFixedSize(image.size()); } void IconButton::hideIconLabel(){ m_iconLabel->hide(); } void IconButton::updateStyle(){ style()->unpolish(this); style()->polish(this); update(); } void IconButton::enterEvent(QEvent *event){ Q_EMIT mouseEntered(text()); QPushButton::enterEvent(event); } void IconButton::leaveEvent(QEvent *event){ Q_EMIT mouseLeaved(text()); QPushButton::leaveEvent(event); } DWIDGET_BEGIN_NAMESPACE DButtonList::DButtonList(QWidget *parent) : QListWidget(parent) { DThemeManager::registerWidget(this); setSelectionMode(DButtonList::NoSelection); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollMode(ScrollPerItem); setResizeMode(Adjust); setItemSize(200, BUTTON_HEIGHT); m_buttonGroup = new QButtonGroup(this); m_buttonGroup->setExclusive(true); initConnect(); } void DButtonList::initMargins(int leftMargin, int rightMargin, int imageLeftMargin){ m_leftMargin = leftMargin; m_rightMargin = rightMargin; m_imageLeftMargin = imageLeftMargin; } DButtonList::~DButtonList() { } void DButtonList::initConnect(){ connect(m_buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(setButtonChecked(int))); } void DButtonList::setItemWidth(int width){ setGridSize(QSize(width, gridSize().height())); setFixedWidth(gridSize().width()); } void DButtonList::setItemHeight(int height){ setGridSize(QSize(gridSize().width(), height)); } void DButtonList::setItemSize(int width, int height){ setItemSize(QSize(width, height)); } void DButtonList::setItemSize(QSize size){ setGridSize(size); setFixedWidth(gridSize().width()); for(int i=0; i< count(); i++){ itemWidget(item(i))->setFixedHeight(size.height()); } } void DButtonList::addButton(const QString &label){ int index = count(); addButton(label, index); } void DButtonList::addButton(const QString &label, int index){ IconButton* button = new IconButton(":/images/dark/images/tick_hover.png", label, this); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); button->setCheckable(true); connect(button, SIGNAL(mouseEntered(QString)), this, SIGNAL(buttonMouseEntered(QString))); connect(button, SIGNAL(mouseLeaved(QString)), this, SIGNAL(buttonMouseLeaved(QString))); QFrame* borderFrame = new QFrame; borderFrame->setObjectName("BorderFrame"); QVBoxLayout* borderLayout = new QVBoxLayout; borderLayout->addWidget(button); borderLayout->setSpacing(0); borderLayout->setContentsMargins(m_leftMargin, 0, m_rightMargin, 0); borderFrame->setLayout(borderLayout); m_buttonGroup->addButton(button, index); QListWidgetItem* item = new QListWidgetItem(this); addItem(item); setItemWidget(item, borderFrame); setItemSize(gridSize()); } void DButtonList::addButtons(const QStringList &listLabels){ for(int i= 0; i< listLabels.length(); i++) { addButton(listLabels.at(i), i); } } void DButtonList::setButtonChecked(int id){ if (id < m_buttonGroup->buttons().length()){ IconButton* button = reinterpret_cast(m_buttonGroup->button(id)); button->setChecked(true); if (m_buttonGroup->buttons().length() == 1){ button->setProperty("state", "OnlyOne"); button->hideIconLabel(); }else{ button->setProperty("state", "normal"); } button->updateStyle(); Q_EMIT buttonCheckedIndexChanged(id); Q_EMIT buttonChecked(button->text()); } } void DButtonList::checkButtonByIndex(int index){ if (index < m_buttonGroup->buttons().length()){ IconButton* button = reinterpret_cast(m_buttonGroup->button(index)); button->click(); } } IconButton* DButtonList::getButtonByIndex(int index){ if (index < m_buttonGroup->buttons().length()){ IconButton* button = reinterpret_cast(m_buttonGroup->button(index)); return button; }else{ qWarning() << "There is no this index:" << index; } return NULL; } void DButtonList::clear(){ Q_FOREACH (QAbstractButton* button, m_buttonGroup->buttons()) { // qDebug() << static_cast(button)->text(); static_cast(button)->disconnect(); m_buttonGroup->removeButton(static_cast(button)); } QListWidget::clear(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dbuttonlist.h000066400000000000000000000051301325435343100206310ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBUTTONLIST_H #define DBUTTONLIST_H #include #include #include "dtkwidget_global.h" class QButtonGroup; class QLabel; class QPoint; class QResizeEvent; class QEvent; class IconButton : public QPushButton{ Q_OBJECT public: IconButton(const QString& Icon, const QString& text, QWidget* parent=0); void initIconLabel(); void initConnect(); void setIconLeftMargin(int leftMargin); void setIconLabel(const QString& icon); void hideIconLabel(); void updateStyle(); Q_SIGNALS: void mouseEntered(QString label); void mouseLeaved(QString label); protected: void resizeEvent(QResizeEvent* event); void enterEvent(QEvent* event); void leaveEvent(QEvent* event); private: QLabel* m_iconLabel; QString m_icon; QString m_text; }; DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DButtonList : public QListWidget { Q_OBJECT public: explicit DButtonList(QWidget *parent = 0); ~DButtonList(); void initMargins(int leftMargin, int rightMargin, int imageLeftMargin); IconButton* getButtonByIndex(int index); public Q_SLOTS: void addButton(const QString &label); void addButton(const QString& label, int index); void addButtons(const QStringList& listLabels); void setItemHeight(int height); void setItemWidth(int width); void setItemSize(int width, int height); void setItemSize(QSize size); void checkButtonByIndex(int index); void clear(); private Q_SLOTS: void setButtonChecked(int id); Q_SIGNALS: void buttonChecked(QString label); void buttonCheckedIndexChanged(int index); void buttonMouseEntered(QString label); void buttonMouseLeaved(QString label); private: QButtonGroup* m_buttonGroup = NULL; void initConnect(); int m_leftMargin = 10; int m_rightMargin = 10; int m_imageLeftMargin = 10; }; DWIDGET_END_NAMESPACE #endif // DBUTTONLIST_H dtkwidget-2.0.7.2/src/widgets/dcircleprogress.cpp000066400000000000000000000111531325435343100220050ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dcircleprogress.h" #include "private/dcircleprogress_p.h" #include #include #include #include DWIDGET_USE_NAMESPACE DCircleProgressPrivate::DCircleProgressPrivate(DCircleProgress *q) : DObjectPrivate(q) { m_topLabel.setAttribute(Qt::WA_TranslucentBackground); m_topLabel.setAlignment(Qt::AlignCenter); m_topLabel.setObjectName("TopLabel"); m_bottomLabel.setAttribute(Qt::WA_TranslucentBackground); m_bottomLabel.setAlignment(Qt::AlignCenter); m_bottomLabel.setObjectName("BottomLabel"); m_bottomLabel.hide(); QBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addStretch(); mainLayout->addWidget(&m_topLabel); mainLayout->addWidget(&m_bottomLabel); mainLayout->addStretch(); mainLayout->setSpacing(0); mainLayout->setMargin(0); q->setLayout(mainLayout); } void DCircleProgressPrivate::paint(QPainter *painter) { Q_Q(const DCircleProgress); painter->setRenderHints(QPainter::Antialiasing); QPen pen(m_chunkColor); pen.setWidth(m_lineWidth); painter->setPen(pen); const QRect widgetRect = q->rect(); QRect outerCircleRect = widgetRect; outerCircleRect.setWidth(outerCircleRect.width() - (m_lineWidth - 1) * 2); outerCircleRect.setHeight(outerCircleRect.height() - (m_lineWidth - 1) * 2); if (outerCircleRect.width() < outerCircleRect.height()) outerCircleRect.setHeight(outerCircleRect.width()); else outerCircleRect.setWidth(outerCircleRect.height()); outerCircleRect.setTop((widgetRect.height() - outerCircleRect.height()) / 2); outerCircleRect.setLeft((widgetRect.width() - outerCircleRect.width()) / 2); const double percent = double(m_currentValue) / (m_maximumValue - m_minmumValue); const int splitPos = -percent * 16 * 360; painter->drawArc(outerCircleRect, 90 * 16, splitPos); pen.setColor(m_backgroundColor); painter->setPen(pen); painter->drawArc(outerCircleRect, 90 * 16, 16 * 360 + splitPos); } DCircleProgress::DCircleProgress(QWidget *parent) : QWidget(parent), DObject(*new DCircleProgressPrivate(this)) { DThemeManager::registerWidget(this); } int DCircleProgress::value() const { Q_D(const DCircleProgress); return d->m_currentValue; } void DCircleProgress::setValue(int value) { Q_D(DCircleProgress); d->m_currentValue = value; update(); } const QString DCircleProgress::text() const { Q_D(const DCircleProgress); return d->m_topLabel.text(); } void DCircleProgress::setText(const QString &text) { Q_D(DCircleProgress); return d->m_topLabel.setText(text); } const QColor DCircleProgress::backgroundColor() const { Q_D(const DCircleProgress); return d->m_backgroundColor; } void DCircleProgress::setBackgroundColor(const QColor &color) { Q_D(DCircleProgress); d->m_backgroundColor = color; } const QColor DCircleProgress::chunkColor() const { Q_D(const DCircleProgress); return d->m_chunkColor; } void DCircleProgress::setChunkColor(const QColor &color) { Q_D(DCircleProgress); d->m_chunkColor = color; } int DCircleProgress::lineWidth() const { Q_D(const DCircleProgress); return d->m_lineWidth; } void DCircleProgress::setLineWidth(const int width) { Q_D(DCircleProgress); d->m_lineWidth = width; } QLabel *DCircleProgress::topLabel() { Q_D(DCircleProgress); return &d->m_topLabel; } QLabel *DCircleProgress::bottomLabel() { Q_D(DCircleProgress); return &d->m_bottomLabel; } void DCircleProgress::paintEvent(QPaintEvent *e) { Q_D(DCircleProgress); QPainter p(this); d->paint(&p); QWidget::paintEvent(e); } void DCircleProgress::mouseReleaseEvent(QMouseEvent *e) { Q_UNUSED(e) Q_EMIT clicked(); } void DCircleProgress::enterEvent(QEvent *e) { Q_EMIT mouseEntered(); QWidget::enterEvent(e); } void DCircleProgress::leaveEvent(QEvent *e) { Q_EMIT mouseLeaved(); QWidget::leaveEvent(e); } dtkwidget-2.0.7.2/src/widgets/dcircleprogress.h000066400000000000000000000043361325435343100214570ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCIRCLEPROGRESS_H #define DCIRCLEPROGRESS_H #include "dtkwidget_global.h" #include "dthememanager.h" #include "dobject.h" #include #include #include DWIDGET_BEGIN_NAMESPACE class DCircleProgressPrivate; class LIBDTKWIDGETSHARED_EXPORT DCircleProgress : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor DESIGNABLE true) Q_PROPERTY(QColor chunkColor READ chunkColor WRITE setChunkColor DESIGNABLE true) Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth DESIGNABLE true) Q_SIGNALS: void clicked(); void mouseEntered(); void mouseLeaved(); public: explicit DCircleProgress(QWidget *parent = 0); int value() const; void setValue(int value); const QString text() const; void setText(const QString &text); const QColor backgroundColor() const; void setBackgroundColor(const QColor &color); const QColor chunkColor() const; void setChunkColor(const QColor &color); int lineWidth() const; void setLineWidth(const int width); QLabel *topLabel(); QLabel *bottomLabel(); Q_SIGNALS: void valueChanged(const int value) const; protected: void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; void enterEvent(QEvent *e) Q_DECL_OVERRIDE; void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DCircleProgress) }; DWIDGET_END_NAMESPACE #endif // DCIRCLEPROGRESS_H dtkwidget-2.0.7.2/src/widgets/dclipeffectwidget.cpp000066400000000000000000000124231325435343100222700ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dclipeffectwidget.h" #include #include #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE class DClipEffectWidgetPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DClipEffectWidgetPrivate(DClipEffectWidget *qq); void updateImage(); QImage image; QRect imageGeometry; QPainterPath path; QMargins margins; QWidgetList parentList; Q_DECLARE_PUBLIC(DClipEffectWidget) }; DClipEffectWidgetPrivate::DClipEffectWidgetPrivate(DClipEffectWidget *qq) : DObjectPrivate(qq) { } /*! * \class DClipEffectWidget * \brief The DClipEffectWidget class clips itself and its content according to a given clip path. * * This class is useful when you want to make rounded widget or things like that. */ /*! * \brief DClipEffectWidget::DClipEffectWidget constructs an instance of DClipEffectWidget. * \param parent is passed to QWidget constructor. */ DClipEffectWidget::DClipEffectWidget(QWidget *parent) : QWidget(parent) , DObject(*new DClipEffectWidgetPrivate(this)) { Q_ASSERT(parent); setAttribute(Qt::WA_TransparentForMouseEvents); setFocusPolicy(Qt::NoFocus); } /*! * \property DClipEffectWidget::margins * \brief This property holds the margin need to be removed before the clip. */ QMargins DClipEffectWidget::margins() const { D_DC(DClipEffectWidget); return d->margins; } /*! * \property DClipEffectWidget::clipPath * \brief This property holds the path used to clip the widget. */ QPainterPath DClipEffectWidget::clipPath() const { D_DC(DClipEffectWidget); return d->path; } void DClipEffectWidget::setMargins(QMargins margins) { D_D(DClipEffectWidget); if (d->margins == margins) return; d->margins = margins; update(); Q_EMIT marginsChanged(margins); } void DClipEffectWidget::setClipPath(const QPainterPath &path) { D_D(DClipEffectWidget); if (d->path == path) return; d->path = path; d->image = QImage(); Q_EMIT clipPathChanged(d->path); update(); } bool DClipEffectWidget::eventFilter(QObject *watched, QEvent *event) { D_D(DClipEffectWidget); if (event->type() == QEvent::Move) { d->image = QImage(); } if (watched != parent()) return false; if (event->type() == QEvent::Paint) { const QPoint &offset = mapTo(window(), QPoint(0, 0)); const QImage &image = window()->backingStore()->handle()->toImage(); if (d->image.isNull()) { d->imageGeometry = image.rect() & parentWidget()->rect().translated(offset); d->image = image.copy(d->imageGeometry); } else { QPaintEvent *e = static_cast(event); QPainter p; const QRect &rect = image.rect() & e->rect().translated(offset); p.begin(&d->image); p.setCompositionMode(QPainter::CompositionMode_Source); p.drawImage(rect.topLeft() - d->imageGeometry.topLeft(), image.copy(rect)); p.end(); } } else if (event->type() == QEvent::Resize) { resize(parentWidget()->size()); } return false; } void DClipEffectWidget::paintEvent(QPaintEvent *event) { D_DC(DClipEffectWidget); if (d->image.isNull()) return; const QRect &rect = event->rect() & this->rect().marginsRemoved(d->margins); const QRect &imageRect = rect.translated(mapTo(window(), QPoint(0, 0)) - d->imageGeometry.topLeft()) & d->imageGeometry; if (!imageRect.isValid()) return; QPainter p(this); QPainterPath newPath; newPath.addRect(this->rect()); newPath -= d->path; p.setRenderHint(QPainter::Antialiasing); p.setClipPath(newPath); p.setCompositionMode(QPainter::CompositionMode_Source); p.drawImage(rect, d->image, imageRect); } void DClipEffectWidget::resizeEvent(QResizeEvent *event) { D_D(DClipEffectWidget); d->image = QImage(); QWidget::resizeEvent(event); } void DClipEffectWidget::showEvent(QShowEvent *event) { D_D(DClipEffectWidget); d->parentList.clear(); QWidget *pw = parentWidget(); while (pw && !pw->isTopLevel()) { d->parentList << pw; pw->installEventFilter(this); pw = pw->parentWidget(); } resize(parentWidget()->size()); QWidget::showEvent(event); } void DClipEffectWidget::hideEvent(QHideEvent *event) { D_D(DClipEffectWidget); for (QWidget *w : d->parentList) w->removeEventFilter(this); d->parentList.clear(); QWidget::hideEvent(event); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dclipeffectwidget.h000066400000000000000000000035571325435343100217450ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCLIPEFFECTWIDGET_H #define DCLIPEFFECTWIDGET_H #include "dtkwidget_global.h" #include "dobject.h" #include DWIDGET_BEGIN_NAMESPACE class DClipEffectWidgetPrivate; class DClipEffectWidget : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QMargins margins READ margins WRITE setMargins NOTIFY marginsChanged) Q_PROPERTY(QPainterPath clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged) public: explicit DClipEffectWidget(QWidget *parent); QMargins margins() const; QPainterPath clipPath() const; public Q_SLOTS: void setMargins(QMargins margins); void setClipPath(const QPainterPath &path); Q_SIGNALS: void marginsChanged(QMargins margins); void clipPathChanged(QPainterPath clipPath); protected: bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DClipEffectWidget) }; DWIDGET_END_NAMESPACE #endif // DCLIPEFFECTWIDGET_H dtkwidget-2.0.7.2/src/widgets/dcolorcombobox.cpp000066400000000000000000000123311325435343100216250ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dcolorcombobox.h" #include "private/dcombobox_p.h" DWIDGET_BEGIN_NAMESPACE class ColorDelegateItem : public DComboBoxItem { Q_OBJECT public: explicit ColorDelegateItem(QWidget *parent = 0); void setData(const QString &color, const QString &title); void setData(const QVariantMap &map) Q_DECL_OVERRIDE; QVariantMap data() const Q_DECL_OVERRIDE; protected: void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: QColor m_color; const int COLOR_BLOCK_WIDTH = 25; const int COLOR_BLOCK_HEIGHT = 10; }; class DComboBoxColorDelegate : public DAbstractComboBoxDelegate { public: explicit DComboBoxColorDelegate(QObject *parent = 0); QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setEditorData(QWidget *editor, const QModelIndex &index) const; }; class DColorComboBoxPrivate : public DComboBoxPrivate { DColorComboBoxPrivate(DColorComboBox *qq); D_DECLARE_PUBLIC(DColorComboBox) }; DColorComboBoxPrivate::DColorComboBoxPrivate(DColorComboBox *qq) : DComboBoxPrivate(qq) { } ColorDelegateItem::ColorDelegateItem(QWidget *parent) : DComboBoxItem(parent) { } void ColorDelegateItem::setData(const QString &color, const QString &title) { m_color.setNamedColor(color); setText(title); update(); } void ColorDelegateItem::setData(const QVariantMap &map) { setData(map["color"].toString(), map["title"].toString()); } QVariantMap ColorDelegateItem::data() const { QVariantMap map; map["color"] = m_color.name(); map["title"] = text(); return map; } void ColorDelegateItem::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QRect colorRect(MENU_ITEM_LEFT_MARGIN, height() / 2 - COLOR_BLOCK_HEIGHT / 2, COLOR_BLOCK_WIDTH, COLOR_BLOCK_HEIGHT); QBrush b(m_color); painter.fillRect(colorRect, b); //draw header color QRect textRect(colorRect.x() + colorRect.width() + TEXT_LEFT_MARGIN, 0, width(), height()); painter.drawText(textRect, Qt::AlignVCenter | Qt::AlignLeft, text()); //draw title } DComboBoxColorDelegate::DComboBoxColorDelegate(QObject *parent) : DAbstractComboBoxDelegate(parent) { } QWidget * DComboBoxColorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(option) Q_UNUSED(index) ColorDelegateItem * editor = new ColorDelegateItem(parent); editor->setFixedHeight(MENU_ITEM_HEIGHT); return editor; } void DComboBoxColorDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QJsonObject dataObj = index.model()->data(index, Qt::DisplayRole).toJsonValue().toObject(); if (dataObj.isEmpty()) return; ColorDelegateItem *colorItem = static_cast(editor); QString color = "#FFFFFFFF"; QString title = ""; if (dataObj.contains("itemTitle")) title = dataObj.value("itemTitle").toString(); if (dataObj.contains("itemColor")) color = dataObj.value("itemColor").toString(); if (colorItem) colorItem->setData(color, title); } DColorComboBox::DColorComboBox(QWidget *parent) : DComboBox(*new DColorComboBoxPrivate(this), parent) { DComboBoxColorDelegate *d = new DComboBoxColorDelegate(this); setItemDelegate(d); setModel(new DComboBoxModel(this)); d_func()->setMaskLabel(new ColorDelegateItem(this)); connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChange(int))); } void DColorComboBox::addData(const QColor &color, const QString &title) { QJsonObject colorObj; colorObj.insert("itemTitle", QJsonValue(title)); colorObj.insert("itemColor", color.name(QColor::HexArgb)); dcomboBoxModel()->append(colorObj); // Make the combo boxes always displayed. view()->openPersistentEditor(dcomboBoxModel()->getModelIndex(dcomboBoxModel()->count() - 1)); } void DColorComboBox::addData(const QString &color, const QString &title) { QJsonObject colorObj; colorObj.insert("itemTitle", QJsonValue(title)); colorObj.insert("itemColor", color); dcomboBoxModel()->append(colorObj); // Make the combo boxes always displayed. view()->openPersistentEditor(dcomboBoxModel()->getModelIndex(dcomboBoxModel()->count() - 1)); } void DColorComboBox::onCurrentIndexChange(int index) { QJsonObject colorObj = dcomboBoxModel()->getJsonData(index); Q_EMIT currentColorChange(QColor(colorObj["itemColor"].toString())); } DWIDGET_END_NAMESPACE #include "dcolorcombobox.moc" dtkwidget-2.0.7.2/src/widgets/dcolorcombobox.h000066400000000000000000000031471325435343100212770ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCOLORCOMBOBOX_H #define DCOLORCOMBOBOX_H #include #include #include #include #include #include #include #include #include #include #include "dtkwidget_global.h" #include "dcomboboxmodel.h" #include "dcombobox.h" #include "dabstractcomboboxdelegate.h" DWIDGET_BEGIN_NAMESPACE class DColorComboBoxPrivate; class LIBDTKWIDGETSHARED_EXPORT DColorComboBox : public DComboBox { Q_OBJECT public: explicit DColorComboBox(QWidget *parent = 0); void addData(const QColor &color, const QString &title); void addData(const QString &color, const QString &title); Q_SIGNALS: void currentColorChange(QColor color); public Q_SLOTS: void onCurrentIndexChange(int index); private: D_DECLARE_PRIVATE(DColorComboBox) }; DWIDGET_END_NAMESPACE #endif // DCOLORCOMBOBOX_H dtkwidget-2.0.7.2/src/widgets/dcombobox.cpp000066400000000000000000000212631325435343100205720ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include "private/dcombobox_p.h" #include "dcombobox.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE DComboBoxPrivate::DComboBoxPrivate(DComboBox *parent) : DObjectPrivate(parent) { } void DComboBoxPrivate::init() { D_Q(DComboBox); initInsideFrame(); //TODO, just work on ediable q->setMaxVisibleItems(MAX_VISIBLE_ITEMS); //default view not support ::item sub-control q->setView(new QListView()); q->view()->setObjectName("DComboBoxItemView"); q->view()->setAutoScroll(true); setMaskLabel(new DComboBoxItem(q)); q->connect(q, SIGNAL(currentIndexChanged(int)), q, SLOT(_q_slotCurrentIndexChange(int))); QObject::connect(q->view(), &QAbstractItemView::entered, q, [ = ](QModelIndex index) { if (hoveredItem) { hoveredItem->setHovered(false); } DComboBoxItem *item = qobject_cast(q->view()->indexWidget(index)); if (item) { item->setHovered(true); hoveredItem = item; } hoverIndex = index; }); restylePopupEnds(); } //Bypassing the problem here //qss can't draw box-shadow void DComboBoxPrivate::initInsideFrame() { D_Q(DComboBox); QFrame *insideFrame = new QFrame(q); insideFrame->raise(); insideFrame->setAttribute(Qt::WA_TransparentForMouseEvents); insideFrame->setObjectName("DComboxInsideFrame"); //the sub-widget of QCombobox can't Inherits the style sheet from QCombobox //so, read the QCombobox's style sheet and set to it sub-widget insideFrame->setStyleSheet(q->styleSheet()); QHBoxLayout *insideLayout = new QHBoxLayout(q); insideLayout->setContentsMargins(OUTSIDE_BORDER_WIDTH, OUTSIDE_BORDER_WIDTH, OUTSIDE_BORDER_WIDTH, OUTSIDE_BORDER_WIDTH); insideLayout->addWidget(insideFrame); } void DComboBoxPrivate::restylePopupEnds() { D_Q(DComboBox); QList children = q->findChildren(); bool isPopupTopEnd = true; for (QWidget *w : children) { if (w->metaObject()->className() == QLatin1String("QComboBoxPrivateScroller")) { w->setFixedHeight(12); w->setStyleSheet("background: transparent"); QHBoxLayout *layout = new QHBoxLayout(w); layout->setContentsMargins(0, 0, 0, 0); QFrame *f = new QFrame(w); if (isPopupTopEnd) { isPopupTopEnd = false; f->setObjectName("ComboboxPopupTopEnd"); } else { f->setObjectName("ComboboxPopupBottomEnd"); } f->setStyleSheet(q->styleSheet()); f->resize(w->size()); layout->addWidget(f); q->connect(DThemeManager::instance(), &DThemeManager::themeChanged, f, [f, q] { f->setStyleSheet(q->styleSheet()); f->parentWidget()->setStyleSheet(q->styleSheet()); }); } else if (w->metaObject()->className() == QLatin1String("QComboBoxPrivateContainer")) { w->setStyleSheet(q->styleSheet()); } } } void DComboBoxPrivate::_q_slotCurrentIndexChange(int index) { D_Q(DComboBox); if (q->isEditable()) { if (q->currentText().isEmpty()) { DComboBoxModel *m = static_cast(q->model()); q->lineEdit()->setText(m->getJsonData(index)["itemText"].toString()); } else { q->lineEdit()->setText(q->currentText()); } } else { DComboBoxModel *m = static_cast(q->model()); QWidget *w = q->view()->indexWidget(m->getModelIndex(index)); if (w) { w->setFixedWidth(q->width()); QRect rect = q->rect(); rect.setHeight(-1); if (checkedItem) { checkedItem->setChecked(false); } DComboBoxItem *item = qobject_cast(w); if (item) { item->setChecked(true); checkedItem = item; maskLabel->setData(item->data()); } else { maskLabel->setPixmap(w->grab(rect)); } } } } void DComboBoxPrivate::setMaskLabel(DComboBoxItem *label) { D_Q(DComboBox); if (maskLabel) { maskLabel->deleteLater(); } maskLabel = label; maskLabel->setObjectName("DComboBoxTitleMask"); maskLabel->setParent(q); maskLabel->setStyleSheet(q->styleSheet()); maskLabel->setFixedSize(q->size()); } DComboBoxItem::DComboBoxItem(QWidget *parent) : QLabel(parent) { setAttribute(Qt::WA_TransparentForMouseEvents); setAttribute(Qt::WA_TranslucentBackground); } bool DComboBoxItem::checked() const { return m_checked; } void DComboBoxItem::setChecked(bool value) { if (value == m_checked) { return; } m_checked = value; style()->unpolish(this); style()->polish(this); Q_EMIT checkedChanged(m_checked); } bool DComboBoxItem::hovered() const { return m_hovered; } void DComboBoxItem::setHovered(bool value) { if (value == m_hovered) { return; } m_hovered = value; style()->unpolish(this); style()->polish(this); Q_EMIT hoveredChanged(m_hovered); } QVariantMap DComboBoxItem::data() const { QVariantMap map; map["text"] = text(); return map; } void DComboBoxItem::setData(const QVariantMap &map) { if (map.isEmpty()) { return; } setText(map.values().first().toString()); } DComboBox::DComboBox(QWidget *parent) : QComboBox(parent), DObject(*new DComboBoxPrivate(this)) { DThemeManager::registerWidget(this, QStringList({"alert"})); d_func()->init(); } void DComboBox::setFixedSize(int w, int h) { D_D(DComboBox); QComboBox::setFixedSize(w, h); d->maskLabel->setFixedSize(size()); } void DComboBox::setFixedSize(QSize size) { D_D(DComboBox); QComboBox::setFixedSize(size); d->maskLabel->setFixedSize(size); } QModelIndex DComboBox::hoverIndex() const { D_DC(DComboBox); return d->hoverIndex; } QString DComboBox::insensitiveTickImg() const { D_DC(DComboBox); return d->insensitiveTickImg; } bool DComboBox::isAlert() const { D_DC(DComboBox); return d->alert; } DComboBoxModel *DComboBox::dcomboBoxModel() const { return qobject_cast(QComboBox::model()); } void DComboBox::setInsensitiveTickImg(const QString &insensitiveTickImg) { D_D(DComboBox); d->insensitiveTickImg = insensitiveTickImg; } void DComboBox::setAlert(bool alert) { D_D(DComboBox); if (d->alert == alert) { return; } d->alert = alert; Q_EMIT alertChanged(alert); } void DComboBox::setEditable(bool editable) { QComboBox::setEditable(editable); view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); if (lineEdit()) { lineEdit()->setStyleSheet(styleSheet()); } } QString DComboBox::hoverTickImg() const { D_DC(DComboBox); return d->hoverTickImg; } void DComboBox::setHoverTickImg(const QString &hoverTickImg) { D_D(DComboBox); d->hoverTickImg = hoverTickImg; } QString DComboBox::normalTickImg() const { D_DC(DComboBox); return d->normalTickImg; } void DComboBox::setNormalTickImg(const QString &normalTickImg) { D_D(DComboBox); d->normalTickImg = normalTickImg; } DComboBox::DComboBox(DComboBoxPrivate &dd, QWidget *parent) : QComboBox(parent), DObject(dd) { DThemeManager::registerWidget(this, QStringList({"alert"})); d_func()->init(); } void DComboBox::resizeEvent(QResizeEvent *e) { QComboBox::resizeEvent(e); if (!isEditable()) { d_func()->_q_slotCurrentIndexChange(currentIndex()); } } void DComboBox::focusInEvent(QFocusEvent *e) { QComboBox::focusInEvent(e); Q_EMIT focusChanged(true); } void DComboBox::focusOutEvent(QFocusEvent *e) { QComboBox::focusOutEvent(e); Q_EMIT focusChanged(false); } DWIDGET_END_NAMESPACE #include "moc_dcombobox.cpp" dtkwidget-2.0.7.2/src/widgets/dcombobox.h000066400000000000000000000051041325435343100202330ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCOMBOBOX_H #define DCOMBOBOX_H #include #include #include #include #include #include #include #include "dtkwidget_global.h" #include "dobject.h" #include "dconstants.h" #include "dcomboboxmodel.h" DWIDGET_BEGIN_NAMESPACE class DComboBoxPrivate; class D_DECL_DEPRECATED_X("Use QCombobBox directly.") LIBDTKWIDGETSHARED_EXPORT DComboBox : public QComboBox, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QString normalTickImg READ normalTickImg WRITE setNormalTickImg) Q_PROPERTY(QString hoverTickImg READ hoverTickImg WRITE setHoverTickImg) Q_PROPERTY(QString insensitiveTickImg READ insensitiveTickImg WRITE setInsensitiveTickImg) Q_PROPERTY(bool alert READ isAlert WRITE setAlert NOTIFY alertChanged) public: explicit DComboBox(QWidget *parent = 0); void setFixedSize(int w, int h); void setFixedSize(QSize size); QModelIndex hoverIndex() const; QString normalTickImg() const; QString hoverTickImg() const; QString insensitiveTickImg() const; bool isAlert() const; DComboBoxModel *dcomboBoxModel() const; public Q_SLOTS: void setEditable(bool editable); void setNormalTickImg(const QString &normalTickImg); void setHoverTickImg(const QString &hoverTickImg); void setInsensitiveTickImg(const QString &insensitiveTickImg); void setAlert(bool alert); Q_SIGNALS: void alertChanged(bool alert); void focusChanged(bool focus); protected: explicit DComboBox(DComboBoxPrivate &dd, QWidget *parent = 0); void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DComboBox) Q_PRIVATE_SLOT(d_func(), void _q_slotCurrentIndexChange(int index)) }; DWIDGET_END_NAMESPACE #endif // DCOMBOBOX_H dtkwidget-2.0.7.2/src/widgets/dcomboboxmodel.cpp000066400000000000000000000066071325435343100216200ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dcomboboxmodel.h" DWIDGET_USE_NAMESPACE DComboBoxModel::DComboBoxModel(QObject *parent) : QAbstractItemModel(parent) { } QModelIndex DComboBoxModel::index(int row, int, const QModelIndex &) const { return this->createIndex(row,0); } int DComboBoxModel::count() { return this->rowCount(QModelIndex()); } void DComboBoxModel::append(const QJsonObject &dataObj) { insert(count(), dataObj); } void DComboBoxModel::clear() { this->removeRows(0, count()); } QJsonObject DComboBoxModel::getJsonData(int index) { QModelIndex tmpIndex = getModelIndex(index); QJsonObject tmpObj = this->data(tmpIndex,0).toJsonValue().toObject(); return tmpObj; } bool DComboBoxModel::insert(int index, const QJsonObject &dataObj) { if (insertRow(index)) { if (setData(getModelIndex(index),QVariant(dataObj))) return true; else qWarning() << "setData error"; } qWarning() << "insertRow error" ; return false; } void DComboBoxModel::remove(int index, int count) { this->removeRows(index,count); } void DComboBoxModel::set(int index, const QJsonObject &dataObj) { Q_UNUSED(index) Q_UNUSED(dataObj) } void DComboBoxModel::setProperty(int index, const QString &property, const QVariant &value) { Q_UNUSED(index) Q_UNUSED(property) Q_UNUSED(value) } QModelIndex DComboBoxModel::getModelIndex(int row) const { return this->index(row,0,QModelIndex()); } bool DComboBoxModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (index.isValid() && role == Qt::EditRole) { m_dataArray.replace(index.row(),QJsonValue(value.toJsonObject())); Q_EMIT dataChanged(index, index); return true; } return false; } QModelIndex DComboBoxModel::parent(const QModelIndex &child) const { Q_UNUSED(child) return QModelIndex(); } int DComboBoxModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) return m_dataArray.count(); } int DComboBoxModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent) return 1; } QVariant DComboBoxModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); if (index.row() >= m_dataArray.count()) return QVariant(); if (role == Qt::DisplayRole || role == Qt::EditRole) return QVariant(m_dataArray.at(index.row())); else return QVariant(); } bool DComboBoxModel::insertRows(int row, int count, const QModelIndex &parent) { Q_UNUSED(parent) beginInsertRows(QModelIndex(), row, row + count-1); for (int i = row; i < row + count; i++) { m_dataArray.insert(i,QJsonValue()); } endInsertRows(); return true; } dtkwidget-2.0.7.2/src/widgets/dcomboboxmodel.h000066400000000000000000000042261325435343100212600ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCOMBOBOXSIMPLEMODEL_H #define DCOMBOBOXSIMPLEMODEL_H #include #include #include #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DComboBoxModel : public QAbstractItemModel { Q_OBJECT public: explicit DComboBoxModel(QObject *parent = 0); QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; QVariant data(const QModelIndex &index, int role = Qt::EditRole) const Q_DECL_OVERRIDE; QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE; QJsonObject getJsonData(int index); QModelIndex getModelIndex(int row) const; int columnCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; int count(); bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE; bool insertRows(int row, int count, const QModelIndex &parent) Q_DECL_OVERRIDE; bool insert(int index, const QJsonObject &dataObj); void setProperty(int index, const QString &property, const QVariant &value); void set(int index, const QJsonObject &dataObj); void append(const QJsonObject &dataObj); void remove(int index, int count = 1); void clear(); private: QJsonArray m_dataArray; }; DWIDGET_END_NAMESPACE #endif // DCOMBOBOXSIMPLEMODEL_H dtkwidget-2.0.7.2/src/widgets/dconstants.h000066400000000000000000000026121325435343100204400ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCONSTANTS_H #define DCONSTANTS_H #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE //basis width and height const int BUTTON_HEIGHT = 22; const int EXPAND_HEADER_HEIGHT = 30; const int CONTENT_HEADER_HEIGHT = 38; const int RADIO_ITEM_HEIGHT = 30; const int MENU_ITEM_HEIGHT = 24; const int MENU_ITEM_LEFT_MARGIN = 24; //NOT include the tick const int HEADER_LEFT_MARGIN = 14; const int HEADER_RIGHT_MARGIN = 14; const int TEXT_LEFT_MARGIN = 6; const int TEXT_RIGHT_MARGIN = 6; const int BUTTON_MARGIN = 8; const int TEXT_BUTTON_MIN_WIDTH = 70; const int IMAGE_BUTTON_WIDTH = 24; const int FONT_SIZE = 12; const int NORMAL_RADIUS = 3; DWIDGET_END_NAMESPACE #endif //DCONSTANTS_H dtkwidget-2.0.7.2/src/widgets/dcrumbedit.cpp000066400000000000000000000453651325435343100207510ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: zccrs * * Maintainer: zccrs * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dcrumbedit.h" #include "dobject_p.h" #include #include #include #include #include #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE class CrumbObjectInterface : public QObject, public QTextObjectInterface { Q_OBJECT Q_INTERFACES(QTextObjectInterface) public: explicit CrumbObjectInterface(QObject *parent = 0) : QObject(parent) { } QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) Q_DECL_OVERRIDE; void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) Q_DECL_OVERRIDE; }; DCrumbTextFormat::DCrumbTextFormat() : QTextCharFormat(QTextFormat(QTextFormat::InvalidFormat)) { } QColor DCrumbTextFormat::tagColor() const { return colorProperty(QTextFormat::UserProperty); } void DCrumbTextFormat::setTagColor(const QColor &color) { setProperty(QTextFormat::UserProperty, color); } QString DCrumbTextFormat::text() const { return stringProperty(QTextFormat::UserProperty + 1); } void DCrumbTextFormat::setText(const QString &text) { setProperty(QTextFormat::UserProperty + 1, text); } QColor DCrumbTextFormat::textColor() const { return colorProperty(QTextFormat::UserProperty + 2); } void DCrumbTextFormat::setTextColor(const QColor &color) { setProperty(QTextFormat::UserProperty + 2, color); } QBrush DCrumbTextFormat::background() const { return brushProperty(QTextFormat::UserProperty + 3); } void DCrumbTextFormat::setBackground(const QBrush &background) { setProperty(QTextFormat::UserProperty + 3, background); } int DCrumbTextFormat::backgroundRadius() const { return intProperty(QTextFormat::UserProperty + 4); } void DCrumbTextFormat::setBackgroundRadius(int radius) { setProperty(QTextFormat::UserProperty + 4, radius); } DCrumbTextFormat::DCrumbTextFormat(int objectType) { setObjectType(objectType); setBackground(QColor("#76c1ff")); setTextColor(Qt::white); setVerticalAlignment(QTextCharFormat::AlignBaseline); } DCrumbTextFormat::DCrumbTextFormat(const QTextFormat &fmt) : QTextCharFormat(fmt) { } class DCrumbEditPrivate : public DCORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DCrumbEdit) public: DCrumbEditPrivate(DCrumbEdit *qq) : DObjectPrivate(qq) , object(new CrumbObjectInterface(qq)) { } void registerHandler(QAbstractTextDocumentLayout *layout) { D_Q(DCrumbEdit); for (int i = QTextFormat::UserObject + 1; ; ++i) { if (!layout->handlerForObject(i)) { objectType = i; break; } } layout->registerHandler(objectType, object); } bool canAddCrumb(const QString &text) const { return !formats.contains(text); } void makeCrumb(QTextCursor &cursor, const QString &text) { const QString tag_text = text.simplified(); if (tag_text.isEmpty()) return; if (!canAddCrumb(tag_text)) return; D_Q(DCrumbEdit); DCrumbTextFormat format = q->makeTextFormat(); format.setText(tag_text); cursor.insertText(QString(QChar::ObjectReplacementCharacter), format); } bool makeCrumb() { D_Q(DCrumbEdit); QString text = q->toPlainText().remove(QChar::ObjectReplacementCharacter); if (text.isEmpty()) return false; QTextCursor cursor = q->document()->find(text); if (cursor.isNull()) return false; if (splitter.isEmpty()) { makeCrumb(cursor, text); return true; } for (const QString &tag_text : text.split(splitter)) { makeCrumb(cursor, tag_text); } return true; } bool editCrumb(const QPoint &mousePos) { D_Q(DCrumbEdit); QTextCursor cursor = q->cursorForPosition(mousePos); if (cursor.charFormat().objectType() != objectType) return false; DCrumbTextFormat format(cursor.charFormat()); if (format.text().isEmpty()) return false; makeCrumb(); if (mousePos.x() < q->cursorRect().left()) cursor.setPosition(cursor.position() - 1, QTextCursor::KeepAnchor); else cursor.setPosition(cursor.position() + 1, QTextCursor::KeepAnchor); cursor.insertText(format.text()); return true; } QByteArray crumbMapToData(const QList &list) const { QJsonArray array; for (const DCrumbTextFormat &f : list) { if (!f.isValid() || f.isEmpty()) continue; QJsonObject object; object["text"] = f.text(); if (f.tagColor().isValid()) object["tag color"] = f.tagColor().name(); array.append(QJsonValue(object)); } QJsonDocument document; document.setArray(array); return document.toJson(QJsonDocument::Compact); } QList crumbListFromData(const QByteArray &format) const { const QJsonDocument &document = QJsonDocument::fromJson(format); const QJsonArray &array = document.array(); QList list; D_QC(DCrumbEdit); for (const QJsonValue &v : array) { const QJsonObject &object = v.toObject(); if (object.isEmpty()) continue; DCrumbTextFormat format = q->makeTextFormat(); format.setText(object["text"].toString()); if (object.contains("tag color")) format.setTagColor(QColor(object["tag color"].toString())); list << format; } return list; } void _q_onDocumentLayoutChanged() { D_Q(DCrumbEdit); if (!q->sender() || q->sender() == q->document()) registerHandler(q->document()->documentLayout()); } void _q_onCurrentPositionChanged() { D_QC(DCrumbEdit); QTextCursor cursor = q->textCursor(); if (cursor.atEnd()) { return; } cursor.setPosition(cursor.position() + 1); if (cursor.charFormat().objectType() != objectType) return; if (q->textCursor().charFormat().objectType() == objectType) makeCrumb(); } void _q_onTextChanged() { D_Q(DCrumbEdit); bool formatsChanged = false; QTextCursor cursor(q->document()); QSet crumbList; int last_pos = 0; cursor.setPosition(0); formatList.clear(); while (!cursor.atEnd()) { cursor.setPosition(last_pos + 1); if (last_pos == cursor.position()) break; last_pos = cursor.position(); DCrumbTextFormat format(cursor.charFormat()); if (format.objectType() == objectType) { const QString &text = format.text(); if (!text.isEmpty()) { crumbList << text; formatList << text; if (!formats.contains(text)) { formats[text] = format; formatsChanged = true; Q_EMIT q->crumbAdded(text); } } } } Q_FOREACH(const DCrumbTextFormat &f, formats) { if (!crumbList.contains(f.text())) { formats.remove(f.text()); formatsChanged = true; Q_EMIT q->crumbRemoved(f.text()); } } if (formatsChanged) Q_EMIT q->crumbListChanged(); } CrumbObjectInterface *object; int objectType; bool crumbReadOnly = false; int crumbRadius = 2; QString splitter = ","; QStringList formatList; QMap formats; bool dualClickMakeCrumb = false; }; QSizeF CrumbObjectInterface::intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) { Q_UNUSED(doc) Q_UNUSED(posInDocument) const DCrumbTextFormat crumb_format(format); const QFontMetricsF font_metrics(crumb_format.font()); int radius = crumb_format.backgroundRadius(); if (crumb_format.tagColor().isValid()) return QSizeF(font_metrics.width(crumb_format.text()) + font_metrics.height() + radius + 2, font_metrics.height() + 2); return QSizeF(font_metrics.width(crumb_format.text()) + 2 * radius + 2, font_metrics.height() + 2); } void CrumbObjectInterface::drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) { Q_UNUSED(doc) Q_UNUSED(posInDocument) const QRectF new_rect = rect.adjusted(1, 1, -1, -1); const DCrumbTextFormat crumb_format(format); const QFontMetricsF font_metrics(crumb_format.font()); const int radius = crumb_format.backgroundRadius(); QPainterPath background_path; QPainterPath tag_path; const QRectF tag_rect(new_rect.x() + 2, new_rect.y() + 2, font_metrics.height() - 4, font_metrics.height() - 4); tag_path.addEllipse(tag_rect); background_path.addRoundedRect(new_rect, radius, crumb_format.backgroundRadius()); painter->setRenderHint(QPainter::Antialiasing); painter->fillPath(background_path, crumb_format.background()); if (crumb_format.tagColor().isValid()) { painter->fillPath(tag_path, crumb_format.tagColor()); painter->setPen(crumb_format.textColor()); painter->drawText(new_rect.adjusted(tag_rect.width() + 2, 0, -radius, 0), crumb_format.text(), Qt::AlignVCenter | Qt::AlignRight); } else { painter->setPen(crumb_format.textColor()); painter->drawText(new_rect.adjusted(radius, 0, -radius, 0), crumb_format.text()); } } DCrumbEdit::DCrumbEdit(QWidget *parent) : QTextEdit(parent) , DObject(*new DCrumbEditPrivate(this)) { d_func()->registerHandler(document()->documentLayout()); connect(document(), SIGNAL(documentLayoutChanged()), this, SLOT(_q_onDocumentLayoutChanged())); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(_q_onCurrentPositionChanged())); connect(this, SIGNAL(textChanged()), this, SLOT(_q_onTextChanged())); } bool DCrumbEdit::insertCrumb(const DCrumbTextFormat &format, int pos) { if (format.text().isEmpty()) return false; D_DC(DCrumbEdit); if (!d->canAddCrumb(format.text())) return false; QTextCursor cursor = textCursor(); if (pos >= 0) cursor.setPosition(pos); cursor.insertText(QString(QChar::ObjectReplacementCharacter), format); return true; } bool DCrumbEdit::appendCrumb(const DCrumbTextFormat &format) { if (format.text().isEmpty()) return false; D_DC(DCrumbEdit); if (!d->canAddCrumb(format.text())) return false; QTextCursor cursor = textCursor(); cursor.movePosition(QTextCursor::End); cursor.insertText(QString(QChar::ObjectReplacementCharacter), format); return true; } bool DCrumbEdit::insertCrumb(const QString &text, int pos) { DCrumbTextFormat format = makeTextFormat(); format.setText(text); return insertCrumb(format, pos); } bool DCrumbEdit::appendCrumb(const QString &text) { DCrumbTextFormat format = makeTextFormat(); format.setText(text); return appendCrumb(text); } bool DCrumbEdit::containCrumb(const QString &text) const { D_DC(DCrumbEdit); return d->formats.contains(text); } QStringList DCrumbEdit::crumbList() const { D_DC(DCrumbEdit); return d->formatList; } DCrumbTextFormat DCrumbEdit::crumbTextFormat(const QString &text) const { D_DC(DCrumbEdit); return d->formats.value(text); } DCrumbTextFormat DCrumbEdit::makeTextFormat() const { D_DC(DCrumbEdit); DCrumbTextFormat format(d->objectType); format.setFontFamily(font().family()); format.setBackgroundRadius(d->crumbRadius); return format; } DCrumbTextFormat DCrumbEdit::makeTextFormat(DCrumbEdit::CrumbType type) const { D_DC(DCrumbEdit); QString text; DCrumbTextFormat format = makeTextFormat(); switch (type) { case black: text = tr("Black"); break; case white: text = tr("White"); break; case darkGray: text = tr("Dark Gray"); break; case gray: text = tr("Gray"); break; case lightGray: text = tr("Light Gray"); break; case red: text = tr("Red"); break; case green: text = tr("Green"); break; case blue: text = tr("Blue"); break; case cyan: text = tr("Cyan"); break; case magenta: text = tr("Magenta"); break; case yellow: text = tr("Yellow"); break; case darkRed: text = tr("Dark Red"); break; case darkGreen: text = tr("Dark Green"); break; case darkBlue: text = tr("Dark Blue"); break; case darkCyan: text = tr("Dark Cyan"); break; case darkMagenta: text = tr("Dark Magenta"); break; case darkYellow: text = tr("Dark Yellow"); break; default: return format; } format.setTagColor(QColor(static_cast(type))); format.setText(text); return format; } bool DCrumbEdit::dualClickMakeCrumb() const Q_DECL_NOEXCEPT { D_DC(DCrumbEdit); return d->dualClickMakeCrumb; } bool DCrumbEdit::crumbReadOnly() const { D_DC(DCrumbEdit); return d->crumbReadOnly; } int DCrumbEdit::crumbRadius() const { D_DC(DCrumbEdit); return d->crumbRadius; } QString DCrumbEdit::splitter() const { D_DC(DCrumbEdit); return d->splitter; } void DCrumbEdit::setCrumbReadOnly(bool crumbReadOnly) { D_D(DCrumbEdit); d->crumbReadOnly = crumbReadOnly; } void DCrumbEdit::setCrumbRadius(int crumbRadius) { D_D(DCrumbEdit); d->crumbRadius = crumbRadius; } void DCrumbEdit::setSplitter(const QString &splitter) { D_D(DCrumbEdit); d->splitter = splitter; } void DCrumbEdit::setDualClickMakeCrumb(bool flag) Q_DECL_NOEXCEPT { D_D(DCrumbEdit); d->dualClickMakeCrumb = flag; } void DCrumbEdit::paintEvent(QPaintEvent *event) { QPainter p(viewport()); QStyleOptionFrame panel; initStyleOption(&panel); panel.rect = viewport()->rect(); style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this); QTextEdit::paintEvent(event); } void DCrumbEdit::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { D_D(DCrumbEdit); d->makeCrumb(); } else { QTextEdit::keyPressEvent(event); } } void DCrumbEdit::mouseDoubleClickEvent(QMouseEvent *event) { D_D(DCrumbEdit); if (d->dualClickMakeCrumb && d->makeCrumb()) return; if (crumbReadOnly()) return QTextEdit::mouseDoubleClickEvent(event); if (!d->editCrumb(event->pos())) return QTextEdit::mouseDoubleClickEvent(event); } void DCrumbEdit::focusOutEvent(QFocusEvent *event) { D_D(DCrumbEdit); d->makeCrumb(); QTextEdit::focusOutEvent(event); } QMimeData *DCrumbEdit::createMimeDataFromSelection() const { D_DC(DCrumbEdit); QMimeData *mime = new QMimeData(); const QTextCursor &cursor = textCursor(); QStringList::const_iterator current_format = d->formatList.constBegin(); const QString &plain_text = toPlainText(); const QString &selected_text = cursor.selectedText(); int pos = -1; QString text; QList format_list; for (const QChar &ch : plain_text) { ++pos; if (pos >= cursor.selectionEnd()) break; if (ch == QChar::ObjectReplacementCharacter) { if (pos < cursor.selectionStart()) { ++current_format; continue; } const DCrumbTextFormat &f = d->formats.value(*current_format); ++current_format; if (f.text().isEmpty()) continue; if (!text.isEmpty()) text.append(" ").append(f.text()); else text.append(f.text()); format_list << f; } else if (pos < cursor.selectionStart()) { text.append(ch); } } mime->setText(text); mime->setData("deepin/dtkwidget-DCrumbTextFormat-data", selected_text.toUtf8()); mime->setData("deepin/dtkwidget-DCrumbTextFormat-list", d->crumbMapToData(format_list)); return mime; } bool DCrumbEdit::canInsertFromMimeData(const QMimeData *source) const { if (source->hasFormat("deepin/dtkwidget-DCrumbTextFormat-data")) return true; return QTextEdit::canInsertFromMimeData(source); } void DCrumbEdit::insertFromMimeData(const QMimeData *source) { if (!source->hasFormat("deepin/dtkwidget-DCrumbTextFormat-data")) QTextEdit::insertFromMimeData(source); const QString &plain_text = QString::fromUtf8(source->data("deepin/dtkwidget-DCrumbTextFormat-data")); if (plain_text.isEmpty()) return; D_DC(DCrumbEdit); const QList &list = d->crumbListFromData(source->data("deepin/dtkwidget-DCrumbTextFormat-list")); QList::const_iterator current_format = list.constBegin(); QString text; textCursor().beginEditBlock(); for (const QChar &ch : plain_text) { if (ch == QChar::ObjectReplacementCharacter) { if (!text.isEmpty()) { textCursor().insertText(text); text.clear(); } insertCrumb(*current_format); ++current_format; } else { text.append(ch); } } if (!text.isEmpty()) textCursor().insertText(text); textCursor().endEditBlock(); } DWIDGET_END_NAMESPACE #include "moc_dcrumbedit.cpp" #include "dcrumbedit.moc" dtkwidget-2.0.7.2/src/widgets/dcrumbedit.h000066400000000000000000000107521325435343100204060ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: zccrs * * Maintainer: zccrs * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCRUMBEDIT_H #define DCRUMBEDIT_H #include #include "dobject.h" #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DCrumbTextFormat : public QTextCharFormat { public: DCrumbTextFormat(); QColor tagColor() const; void setTagColor(const QColor &color); QString text() const; void setText(const QString &text); QColor textColor() const; void setTextColor(const QColor &color); QBrush background() const; void setBackground(const QBrush &background); int backgroundRadius() const; void setBackgroundRadius(int radius); protected: DCrumbTextFormat(int objectType); explicit DCrumbTextFormat(const QTextFormat &fmt); friend class CrumbObjectInterface; friend class DCrumbEdit; friend class DCrumbEditPrivate; }; class DCrumbEditPrivate; class LIBDTKWIDGETSHARED_EXPORT DCrumbEdit : public QTextEdit, public DCORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(bool crumbReadOnly READ crumbReadOnly WRITE setCrumbReadOnly) Q_PROPERTY(int crumbRadius READ crumbRadius WRITE setCrumbRadius) Q_PROPERTY(QString splitter READ splitter WRITE setSplitter) Q_PROPERTY(bool dualClickMakeCrumb READ dualClickMakeCrumb WRITE setDualClickMakeCrumb) public: enum CrumbType { black = Qt::black, white = Qt::white, darkGray = Qt::darkGray, gray = Qt::gray, lightGray = Qt::lightGray, red = Qt::red, green = Qt::green, blue = Qt::blue, cyan = Qt::cyan, magenta = Qt::magenta, yellow = Qt::yellow, darkRed = Qt::darkRed, darkGreen = Qt::darkGreen, darkBlue = Qt::darkBlue, darkCyan = Qt::darkCyan, darkMagenta = Qt::darkMagenta, darkYellow = Qt::darkYellow }; explicit DCrumbEdit(QWidget *parent = 0); bool insertCrumb(const DCrumbTextFormat &format, int pos = -1); bool insertCrumb(const QString &text, int pos = -1); bool appendCrumb(const DCrumbTextFormat &format); bool appendCrumb(const QString &text); bool containCrumb(const QString &text) const; QStringList crumbList() const; DCrumbTextFormat crumbTextFormat(const QString &text) const; DCrumbTextFormat makeTextFormat() const; DCrumbTextFormat makeTextFormat(CrumbType type) const; bool dualClickMakeCrumb() const Q_DECL_NOEXCEPT; bool crumbReadOnly() const; int crumbRadius() const; QString splitter() const; Q_SIGNALS: void crumbAdded(const QString &text); void crumbRemoved(const QString &text); void crumbListChanged(); public Q_SLOTS: void setCrumbReadOnly(bool crumbReadOnly); void setCrumbRadius(int crumbRadius); void setSplitter(const QString &splitter); void setDualClickMakeCrumb(bool flag) Q_DECL_NOEXCEPT; protected: void paintEvent(QPaintEvent *event) override; void keyPressEvent(QKeyEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; void focusOutEvent(QFocusEvent *event) override; QMimeData *createMimeDataFromSelection() const override; bool canInsertFromMimeData(const QMimeData *source) const override; void insertFromMimeData(const QMimeData *source) override; private: using QTextEdit::setDocument; using QTextEdit::document; using QTextEdit::setText; using QTextEdit::setHtml; using QTextEdit::setPlaceholderText; using QTextEdit::insertPlainText; using QTextEdit::insertHtml; using QTextEdit::append; D_DECLARE_PRIVATE(DCrumbEdit) Q_PRIVATE_SLOT(d_func(), void _q_onDocumentLayoutChanged()) Q_PRIVATE_SLOT(d_func(), void _q_onCurrentPositionChanged()) Q_PRIVATE_SLOT(d_func(), void _q_onTextChanged()) }; DWIDGET_END_NAMESPACE #endif // DCRUMBEDIT_H dtkwidget-2.0.7.2/src/widgets/ddialog.cpp000066400000000000000000000457131325435343100202270ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "private/ddialog_p.h" #include "dimagebutton.h" #include "dialog_constants.h" #include "ddialog.h" #include "dthememanager.h" #include "dboxwidget.h" #include "anchors.h" DWIDGET_BEGIN_NAMESPACE DialogButton::DialogButton(const QString &text, QWidget *parent) :QPushButton(text, parent) { } int DialogButton::buttonType() const { return m_buttonType; } void DialogButton::setButtonType(int buttonType) { if (m_buttonType == buttonType) return; m_buttonType = buttonType; Q_EMIT buttonTypeChanged(buttonType); } DDialogPrivate::DDialogPrivate(DDialog *qq) : DAbstractDialogPrivate(qq), fixedStyle(Q_NULLPTR) { } QBoxLayout *DDialogPrivate::getContentLayout() { return contentLayout; } void DDialogPrivate::init() { D_Q(DDialog); // TopLayout topLayout = new QHBoxLayout; topLayout->setContentsMargins(DIALOG::ICON_LAYOUT_LEFT_MARGIN, DIALOG::ICON_LAYOUT_TOP_MARGIN, DIALOG::ICON_LAYOUT_RIGHT_MARGIN, DIALOG::ICON_LAYOUT_BOTTOM_MARGIN); topLayout->setSpacing(DIALOG::ICON_LAYOUT_SPACING); // TopLayout--Icon iconLabel = new QLabel; iconLabel->hide(); iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); topLayout->addWidget(iconLabel); // TopLayout--TextLabel titleLabel = new QLabel; titleLabel->setObjectName("TitleLabel"); titleLabel->hide(); titleLabel->setAttribute(Qt::WA_TransparentForMouseEvents); messageLabel = new QLabel; messageLabel->setObjectName("MessageLabel"); messageLabel->hide(); messageLabel->setAttribute(Qt::WA_TransparentForMouseEvents); QVBoxLayout *textLayout = new QVBoxLayout; textLayout->setContentsMargins(0, 0, 0, 0); textLayout->setSpacing(5); textLayout->addStretch(); textLayout->addWidget(titleLabel, 0, Qt::AlignLeft); textLayout->addWidget(messageLabel, 0, Qt::AlignLeft); textLayout->addStretch(); // TopLayout--ContentLayout contentLayout = new QVBoxLayout; contentLayout->setContentsMargins(0, 0, 0, 0); contentLayout->setSpacing(0); contentLayout->addLayout(textLayout); topLayout->addLayout(contentLayout); // TopLayout--Close button closeButton = new DImageButton(q); closeButton->setObjectName("CloseButton"); closeButton->setFixedSize(DIALOG::CLOSE_BUTTON_WIDTH, DIALOG::CLOSE_BUTTON_HEIGHT); closeButton->setAttribute(Qt::WA_NoMousePropagation); AnchorsBase::setAnchor(closeButton, Qt::AnchorRight, q, Qt::AnchorRight); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); // MainLayout--TopLayout mainLayout->addLayout(topLayout); // MainLayout--ButtonLayout buttonLayout = new QHBoxLayout; buttonLayout->setMargin(0); buttonLayout->setSpacing(0); buttonLayout->setContentsMargins(DIALOG::BUTTON_LAYOUT_LEFT_MARGIN, DIALOG::BUTTON_LAYOUT_TOP_MARGIN, DIALOG::BUTTON_LAYOUT_RIGHT_MARGIN, DIALOG::BUTTON_LAYOUT_BOTTOM_MARGIN); mainLayout->addLayout(buttonLayout); QAction *button_action = new QAction(q); button_action->setShortcuts(QKeySequence::InsertParagraphSeparator); button_action->setAutoRepeat(false); QObject::connect(closeButton, SIGNAL(clicked()), q, SLOT(close())); QObject::connect(button_action, SIGNAL(triggered(bool)), q, SLOT(_q_defaultButtonTriggered())); q->setLayout(mainLayout); q->addAction(button_action); q->setFocusPolicy(Qt::ClickFocus); q->setFocus(); } const QScreen *DDialogPrivate::getScreen() const { D_QC(DDialog); const QScreen *screen = qApp->screens()[qApp->desktop()->screenNumber(q)]; if(screen) return screen; screen = qApp->screens()[qApp->desktop()->screenNumber(QCursor::pos())]; return screen; } QString DDialogPrivate::trimTag(QString origin) const { return origin.replace(QRegularExpression("<.*?>"), ""); } QMap DDialogPrivate::scanTags(QString origin) const { QMap result; QRegExp re("<.*?>"); int index = origin.indexOf(re, 0); int matchLength = 0; while (index >= 0) { result[index] = re.cap(); matchLength = re.matchedLength(); index = origin.indexOf(re, index + matchLength); } return result; } // It's not a perfect solution to elide rich text, but it should be sufficient // for working with rich text only change text token color. QString DDialogPrivate::elideString(QString str, const QFontMetrics &fm, int width) const { QString trimmed = trimTag(str); if (fm.width(trimmed) > width) { QMap info = scanTags(str); QString elided = fm.elidedText(trimmed, Qt::ElideMiddle, width); int elideStart = elided.indexOf("…"); int elideLength = trimmed.length() - elided.length(); QList indexes = info.keys(); std::sort(indexes.begin(), indexes.end()); for (int index : indexes) { if (index <= elideStart) { elided.insert(index, info[index]); } else if (elideStart < index && index <= elideStart + elideLength) { elided.insert(elideStart, info[index]); elideStart += 1; } else { elided.insert(index - elideLength + 1, info[index]); } } return elided; } else { return str; } } void DDialogPrivate::updateSize() { D_Q(DDialog); if (!q->testAttribute(Qt::WA_Resized)) { QSize size = q->sizeHint(); size.setWidth(qMax(size.width(), DIALOG::DEFAULT_WIDTH)); size.setHeight(qMax(size.height(), DIALOG::DEFAULT_HEIGHT)); q->resize(size); q->setAttribute(Qt::WA_Resized, false); } } void DDialogPrivate::_q_onButtonClicked() { D_Q(DDialog); QAbstractButton *button = qobject_cast(q->sender()); if(button) { clickedButtonIndex = buttonList.indexOf(button); q->buttonClicked(clickedButtonIndex, button->text()); if(onButtonClickedClose) q->done(clickedButtonIndex); } } void DDialogPrivate::_q_defaultButtonTriggered() { D_QC(DDialog); QAbstractButton *button = qobject_cast(q->focusWidget()); if (button) button->click(); else if (defaultButton) defaultButton->click(); } DDialog::DDialog(QWidget *parent) : DAbstractDialog(*new DDialogPrivate(this), parent) { DThemeManager::registerWidget(this); d_func()->init(); } DDialog::DDialog(const QString &title, const QString &message, QWidget *parent) : DAbstractDialog(*new DDialogPrivate(this), parent) { DThemeManager::registerWidget(this); d_func()->init(); setTitle(title); setMessage(message); } int DDialog::getButtonIndexByText(const QString &text) const { int i = -1; for(const QAbstractButton *button : getButtons()) { ++i; if(button->text() == text) return i; } return i; } int DDialog::buttonCount() const { D_DC(DDialog); return d->buttonList.count(); } int DDialog::contentCount() const { D_DC(DDialog); return d->contentList.count(); } QList DDialog::getButtons() const { D_DC(DDialog); return d->buttonList; } QList DDialog::getContents() const { D_DC(DDialog); return d->contentList; } QAbstractButton *DDialog::getButton(int index) const { D_DC(DDialog); return d->buttonList.at(index); } QWidget *DDialog::getContent(int index) const { D_DC(DDialog); return d->contentList.at(index); } QString DDialog::title() const { D_DC(DDialog); return d->title; } QString DDialog::message() const { D_DC(DDialog); return d->message; } QIcon DDialog::icon() const { D_DC(DDialog); return d->icon; } QPixmap DDialog::iconPixmap() const { D_DC(DDialog); return *d->iconLabel->pixmap(); } Qt::TextFormat DDialog::textFormat() const { D_DC(DDialog); return d->textFormat; } bool DDialog::onButtonClickedClose() const { D_DC(DDialog); return d->onButtonClickedClose; } void DDialog::setContentLayoutContentsMargins(const QMargins &margins) { D_D(DDialog); d->topLayout->setContentsMargins(margins); } QMargins DDialog::contentLayoutContentsMargins() const { D_DC(DDialog); return d->topLayout->contentsMargins(); } int DDialog::addButton(const QString &text, bool isDefault, ButtonType type) { int index = buttonCount(); insertButton(index, text, isDefault, type); return index; } int DDialog::addButtons(const QStringList &text) { int index = buttonCount(); insertButtons(index, text); return index; } void DDialog::insertButton(int index, const QString &text, bool isDefault, ButtonType type) { DialogButton *button = new DialogButton(text); button->setObjectName("ActionButton"); button->setButtonType(type); button->setAttribute(Qt::WA_NoMousePropagation); button->setFixedHeight(DIALOG::BUTTON_HEIGHT); insertButton(index, button, isDefault); } void DDialog::insertButton(int index, QAbstractButton *button, bool isDefault) { D_D(DDialog); QLabel* label = new QLabel; label->setObjectName("VLine"); label->setFixedWidth(1); label->hide(); if (index > 0 && index >= buttonCount()) { QLabel *label = qobject_cast(d->buttonLayout->itemAt(d->buttonLayout->count() - 1)->widget()); if(label) label->show(); } d->buttonLayout->insertWidget(index * 2, button); d->buttonList << button; d->buttonLayout->insertWidget(index * 2 + 1, label); connect(button, SIGNAL(clicked(bool)), this, SLOT(_q_onButtonClicked())); if (isDefault) { setDefaultButton(button); } const QString &text = button->text(); if (text.count() == 2) { for (const QChar &ch : text) { switch (ch.script()) { case QChar::Script_Han: case QChar::Script_Katakana: case QChar::Script_Hiragana: case QChar::Script_Hangul: break; default: return; } } button->setText(QString().append(text.at(0)).append(QChar::Nbsp).append(text.at(1))); } } void DDialog::insertButtons(int index, const QStringList &text) { for(int i = 0; i < text.count(); ++i) { insertButton(index + i, text[i]); } } void DDialog::removeButton(int index) { D_D(DDialog); QLabel *label = qobject_cast(d->buttonLayout->itemAt(index * 2 + 1)->widget()); QAbstractButton * button = qobject_cast(d->buttonLayout->itemAt(index * 2)->widget()); if(label) { d->buttonLayout->removeWidget(label); label->deleteLater(); } if(button) { d->buttonLayout->removeWidget(button); button->deleteLater(); } if(index > 0 && index == buttonCount() - 1) { QLabel *label = qobject_cast(d->buttonLayout->itemAt(d->buttonLayout->count() - 1)->widget()); if(label) label->hide(); } d->buttonList.removeAt(index); } void DDialog::removeButton(QAbstractButton *button) { removeButton(getButtons().indexOf(button)); } void DDialog::removeButtonByText(const QString &text) { int index = getButtonIndexByText(text); if(index >= 0) removeButton(index); } void DDialog::clearButtons() { D_D(DDialog); d->buttonList.clear(); while(d->buttonLayout->count()) { QLayoutItem *item = d->buttonLayout->takeAt(0); item->widget()->deleteLater(); delete item; } } bool DDialog::setDefaultButton(int index) { if(index < 0) return false; setDefaultButton(getButton(index)); return true; } bool DDialog::setDefaultButton(const QString &str) { return setDefaultButton(getButtonIndexByText(str)); } void DDialog::setDefaultButton(QAbstractButton *button) { D_D(DDialog); d->defaultButton = button; } void DDialog::addContent(QWidget *widget, Qt::Alignment alignment) { D_DC(DDialog); int index = d->contentLayout->count(); insertContent(index, widget, alignment); } void DDialog::insertContent(int index, QWidget *widget, Qt::Alignment alignment) { D_D(DDialog); d->contentLayout->insertWidget(index + DIALOG::CONTENT_INSERT_OFFSET, widget, 0, alignment); d->contentList << widget; } void DDialog::removeContent(QWidget *widget, bool isDelete) { D_D(DDialog); d->contentLayout->removeWidget(widget); if(isDelete) widget->deleteLater(); d->contentList.removeOne(widget); } void DDialog::clearContents(bool isDelete) { D_D(DDialog); for(QWidget *widget : d->contentList) d->contentLayout->removeWidget(widget); if(isDelete) { qDeleteAll(d->contentList); } d->contentList.clear(); } void DDialog::setSpacing(int spacing) { D_D(DDialog); d->contentLayout->setSpacing(spacing); } void DDialog::addSpacing(int spacing) { D_D(DDialog); d->contentLayout->addSpacing(spacing); } void DDialog::insertSpacing(int index, int spacing) { D_D(DDialog); d->contentLayout->insertSpacing(index, spacing); } void DDialog::clearSpacing() { D_D(DDialog); for(int i = 0; i < d->contentLayout->count(); ++i) { QLayoutItem *item = d->contentLayout->itemAt(i); if(item->spacerItem()) { delete d->contentLayout->takeAt(i); } } } void DDialog::setButtonText(int index, const QString &text) { QAbstractButton *button = getButton(index); button->setText(text); } void DDialog::setButtonIcon(int index, const QIcon &icon) { QAbstractButton *button = getButton(index); button->setIcon(icon); } void DDialog::setTitle(const QString &title) { D_D(DDialog); if (d->title == title) return; d->title = title; d->titleLabel->setText(title); d->titleLabel->setHidden(title.isEmpty()); Q_EMIT titleChanged(title); } void DDialog::setMessage(const QString &message) { D_D(DDialog); if (d->message == message) return; d->message = message; d->messageLabel->setText(message); d->messageLabel->setHidden(message.isEmpty()); Q_EMIT messageChanged(message); } void DDialog::setIcon(const QIcon &icon) { D_D(DDialog); d->icon = icon; if(!icon.isNull()) { auto size = QSize(64, 64); size = icon.availableSizes().value(0, size); auto pixmap = icon.pixmap(size); setIconPixmap(pixmap); } } void DDialog::setIconPixmap(const QPixmap &iconPixmap) { D_D(DDialog); d->iconLabel->setPixmap(iconPixmap); if(iconPixmap.isNull()) { d->iconLabel->hide(); } else { d->iconLabel->show(); } } void DDialog::setTextFormat(Qt::TextFormat textFormat) { D_D(DDialog); if (d->textFormat == textFormat) return; d->textFormat = textFormat; d->titleLabel->setTextFormat(textFormat); d->messageLabel->setTextFormat(textFormat); Q_EMIT textFormatChanged(textFormat); } void DDialog::setOnButtonClickedClose(bool onButtonClickedClose) { D_D(DDialog); d->onButtonClickedClose = onButtonClickedClose; } int DDialog::exec() { D_D(DDialog); d->clickedButtonIndex = -1; int code = DAbstractDialog::exec(); return d->clickedButtonIndex >= 0 ? d->clickedButtonIndex : code; } DDialog::DDialog(DDialogPrivate &dd, QWidget *parent) : DAbstractDialog(dd, parent) { DThemeManager::registerWidget(this); d_func()->init(); } void DDialog::showEvent(QShowEvent *event) { D_D(DDialog); DAbstractDialog::showEvent(event); setAttribute(Qt::WA_Resized, false); d->updateSize(); Q_EMIT visibleChanged(isVisible()); } void DDialog::hideEvent(QHideEvent *event) { Q_EMIT aboutToClose(); DAbstractDialog::hideEvent(event); done(-1); Q_EMIT visibleChanged(isVisible()); Q_EMIT closed(); } void DDialog::childEvent(QChildEvent *event) { DAbstractDialog::childEvent(event); D_D(DDialog); if (event->added()) { if (d->closeButton) { d->closeButton->raise(); } QStyle *style = d->fixedStyle; if (!style) { style = QStyleFactory::create("dlight"); if (style) { d->fixedStyle = style; style->setParent(this); } } QWidget *child = qobject_cast(event->child()); if (child) { if (style) { child->setStyle(style); } // TODO(hualet): apply the rule to all dwidgets. // Just tried with no luck, DPsswordWidget's style goes wrong, // no time to deal with this detail, leave it alone for now. if (child->inherits("Dtk::Widget::DLineEdit")) { DThemeManager *dtm = DThemeManager::instance(); // NOTE(sbw): want to force reset to light theme. // FIXME(zccrs): fixation the DLineEdit widget theme to light. dtm->setTheme(child, "light"); } } } } void DDialog::resizeEvent(QResizeEvent *event) { DAbstractDialog::resizeEvent(event); D_D(DDialog); d->titleLabel->setWordWrap(false); int labelMaxWidth = maximumWidth() - d->closeButton->width() - d->titleLabel->x(); if (d->titleLabel->sizeHint().width() > labelMaxWidth) { d->titleLabel->setFixedWidth(labelMaxWidth); d->titleLabel->setWordWrap(true); d->titleLabel->setFixedHeight(d->titleLabel->sizeHint().height()); } d->messageLabel->setWordWrap(false); labelMaxWidth = maximumWidth() - d->closeButton->width() - d->messageLabel->x(); if (d->messageLabel->sizeHint().width() > labelMaxWidth) { d->messageLabel->setFixedWidth(labelMaxWidth); d->messageLabel->setWordWrap(true); d->messageLabel->setFixedHeight(d->messageLabel->sizeHint().height()); } } DWIDGET_END_NAMESPACE #include "moc_ddialog.cpp" dtkwidget-2.0.7.2/src/widgets/ddialog.h000066400000000000000000000111001325435343100176530ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DDIALOG_H #define DDIALOG_H #include #include "dabstractdialog.h" class QAbstractButton; class QButtonGroup; class QLabel; class QCloseEvent; class QVBoxLayout; DWIDGET_BEGIN_NAMESPACE class DDialogPrivate; class DDialog : public DAbstractDialog { Q_OBJECT Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged) Q_PROPERTY(QIcon icon READ icon WRITE setIcon) Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap) Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) Q_PROPERTY(bool onButtonClickedClose READ onButtonClickedClose WRITE setOnButtonClickedClose) public: enum ButtonType { ButtonNormal, ButtonWarning, ButtonRecommend }; explicit DDialog(QWidget *parent = 0); explicit DDialog(const QString &title, const QString& message, QWidget *parent = 0); int getButtonIndexByText(const QString &text) const; int buttonCount() const; int contentCount() const; QList getButtons() const; QList getContents() const; QAbstractButton* getButton(int index) const; QWidget* getContent(int index) const; QString title() const; QString message() const; QIcon icon() const; QPixmap iconPixmap() const; Qt::TextFormat textFormat() const; bool onButtonClickedClose() const; void setContentLayoutContentsMargins(const QMargins &margins); QMargins contentLayoutContentsMargins() const; Q_SIGNALS: void aboutToClose(); void closed(); void buttonClicked(int index, const QString &text); void titleChanged(QString title); void messageChanged(QString massage); void textFormatChanged(Qt::TextFormat textFormat); void sizeChanged(QSize size); void visibleChanged(bool visible); public Q_SLOTS: int addButton(const QString &text, bool isDefault = false, ButtonType type = ButtonNormal); int addButtons(const QStringList &text); void insertButton(int index, const QString &text, bool isDefault = false, ButtonType type = ButtonNormal); void insertButton(int index, QAbstractButton* button, bool isDefault = false); void insertButtons(int index, const QStringList &text); void removeButton(int index); void removeButton(QAbstractButton *button); void removeButtonByText(const QString &text); void clearButtons(); bool setDefaultButton(int index); bool setDefaultButton(const QString &str); void setDefaultButton(QAbstractButton *button); void addContent(QWidget *widget, Qt::Alignment alignment = 0); void insertContent(int index, QWidget *widget, Qt::Alignment alignment = 0); void removeContent(QWidget *widget, bool isDelete = true); void clearContents(bool isDelete = true); void setSpacing(int spacing); void addSpacing(int spacing); void insertSpacing(int index, int spacing); void clearSpacing(); void setButtonText(int index, const QString &text); void setButtonIcon(int index, const QIcon &icon); void setTitle(const QString &title); void setMessage(const QString& message); void setIcon(const QIcon &icon); void setIconPixmap(const QPixmap &iconPixmap); void setTextFormat(Qt::TextFormat textFormat); void setOnButtonClickedClose(bool onButtonClickedClose); int exec() Q_DECL_OVERRIDE; protected: explicit DDialog(DDialogPrivate &dd, QWidget *parent = 0); void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE; void childEvent(QChildEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DDialog) Q_PRIVATE_SLOT(d_func(), void _q_onButtonClicked()) Q_PRIVATE_SLOT(d_func(), void _q_defaultButtonTriggered()) }; DWIDGET_END_NAMESPACE #endif // DDIALOG_H dtkwidget-2.0.7.2/src/widgets/denhancedwidget.cpp000066400000000000000000000076501325435343100217370ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include "denhancedwidget.h" DWIDGET_BEGIN_NAMESPACE class DEnhancedWidgetPrivate { explicit DEnhancedWidgetPrivate(DEnhancedWidget *qq): q_ptr(qq) {} QSize old_size; QPoint old_pos; QWidget *target = NULL; bool enabled = true; DEnhancedWidget *q_ptr; Q_DECLARE_PUBLIC(DEnhancedWidget) }; DEnhancedWidget::DEnhancedWidget(QWidget *w, QObject *parent): QObject(parent), d_ptr(new DEnhancedWidgetPrivate(this)) { if (w) { Q_D(DEnhancedWidget); d->target = w; w->installEventFilter(this); } } DEnhancedWidget::~DEnhancedWidget() { delete d_ptr; } QWidget *DEnhancedWidget::target() const { Q_D(const DEnhancedWidget); return d->target; } bool DEnhancedWidget::enabled() const { Q_D(const DEnhancedWidget); return d->enabled; } void DEnhancedWidget::setTarget(QWidget *target) { Q_D(DEnhancedWidget); if (d->target == target) { return; } if (d->enabled && d->target) { d->target->removeEventFilter(this); } if (d->enabled && target) { target->installEventFilter(this); } d->target = target; Q_EMIT targetChanged(target); } void DEnhancedWidget::setEnabled(bool enabled) { Q_D(DEnhancedWidget); if (d->enabled == enabled) { return; } if (d->target) { if (enabled) { d->target->installEventFilter(this); } else { d->target->removeEventFilter(this); } } d->enabled = enabled; Q_EMIT enabledChanged(enabled); } bool DEnhancedWidget::eventFilter(QObject *o, QEvent *e) { Q_D(DEnhancedWidget); if (o == d->target) { switch (e->type()) { case QEvent::Resize: { QResizeEvent *event = static_cast(e); if (event) { QSize size = event->size(); if (size.width() != d->old_size.width()) { Q_EMIT widthChanged(size.width()); } if (size.height() != d->old_size.height()) { Q_EMIT heightChanged(size.height()); } if (size != d->old_size) { Q_EMIT sizeChanged(size); } d->old_size = size; } break; } case QEvent::Move: { QMoveEvent *event = static_cast(e); if (event) { QPoint pos = event->pos(); if (pos.x() != d->old_pos.x()) { Q_EMIT xChanged(pos.x()); } if (pos.y() != d->old_pos.y()) { Q_EMIT yChanged(pos.y()); } if (pos != d->old_pos) { Q_EMIT positionChanged(pos); } d->old_pos = pos; } break; } case QEvent::Show: { Q_EMIT showed(); break; } default: break; } } return false; } DEnhancedWidget::DEnhancedWidget(DEnhancedWidgetPrivate *dd, QWidget *w, QObject *parent): QObject(parent), d_ptr(dd) { if (w) { w->installEventFilter(this); } } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/denhancedwidget.h000066400000000000000000000036301325435343100213760ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DENHANCEDWIDGET_H #define DENHANCEDWIDGET_H #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DEnhancedWidgetPrivate; class DEnhancedWidget: public QObject { Q_OBJECT Q_PROPERTY(QWidget *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) public: explicit DEnhancedWidget(QWidget *target, QObject *parent = 0); ~DEnhancedWidget(); QWidget *target() const; bool enabled() const; public Q_SLOTS: void setTarget(QWidget *target); void setEnabled(bool enabled); Q_SIGNALS: void xChanged(int x); void yChanged(int y); void positionChanged(const QPoint &point); void widthChanged(int width); void heightChanged(int height); void sizeChanged(const QSize &size); void targetChanged(QWidget *target); void enabledChanged(bool enabled); void showed(); protected: bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; private: explicit DEnhancedWidget(DEnhancedWidgetPrivate *dd, QWidget *w, QObject *parent = 0); DEnhancedWidgetPrivate *d_ptr; Q_DECLARE_PRIVATE(DEnhancedWidget) }; DWIDGET_END_NAMESPACE #endif // DENHANCEDWIDGET_H dtkwidget-2.0.7.2/src/widgets/dexpandgroup.cpp000066400000000000000000000054541325435343100213220ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dexpandgroup.h" DWIDGET_USE_NAMESPACE DExpandGroup::DExpandGroup(QObject *parent) : QObject(parent) { } QList DExpandGroup::expands() const { return m_expandMap.values(); } DBaseExpand *DExpandGroup::checkedExpand() const { if (m_checkedMap.isEmpty()) return NULL; else return m_checkedMap.first(); } DBaseExpand *DExpandGroup::expand(int id) const { return m_expandMap.value(id); } void DExpandGroup::addExpand(DBaseExpand *expand, int id) { if (m_expandMap.values().indexOf(expand) == -1){ if (id == -1){ int maxId = -1; Q_FOREACH (int tmp, m_expandMap.keys()) { maxId = qMax(tmp, maxId); } id = maxId + 1; } m_expandMap.insert(id, expand); connect(expand, &DBaseExpand::expandChange, this, &DExpandGroup::onExpandChanged); } } void DExpandGroup::setId(DBaseExpand *expand, int id) { int index = m_expandMap.values().indexOf(expand); if (index != -1){ m_expandMap.remove(m_expandMap.keys().at(index)); addExpand(expand, id); } } void DExpandGroup::removeExpand(DBaseExpand *expand) { int index = m_expandMap.values().indexOf(expand); m_expandMap.remove(m_expandMap.keys().at(index)); } int DExpandGroup::checkedId() const { if (m_checkedMap.isEmpty()) return -1; else return m_checkedMap.firstKey(); } int DExpandGroup::id(DBaseExpand *expand) const { return m_expandMap.keys().at(m_expandMap.values().indexOf(expand)); } void DExpandGroup::onExpandChanged(bool v) { DBaseExpand *dSender = qobject_cast(sender()); if (!dSender || dSender == checkedExpand() || !v) return; m_checkedMap.clear(); int checkedIndex = m_expandMap.values().indexOf(dSender); m_checkedMap.insert(m_expandMap.keys().at(checkedIndex), dSender); QList expandList = m_expandMap.values(); for (int i = 0; i < expandList.count(); i ++){ DBaseExpand *target = expandList.at(i); if (target != dSender && target->expand()) target->setExpand(false); } } dtkwidget-2.0.7.2/src/widgets/dexpandgroup.h000066400000000000000000000027741325435343100207710ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef EXPANDGROUP_H #define EXPANDGROUP_H #include #include #include #include "dtkwidget_global.h" #include "dbaseexpand.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DExpandGroup : public QObject { Q_OBJECT public: explicit DExpandGroup(QObject *parent = 0); QList expands() const; DBaseExpand * checkedExpand() const; DBaseExpand * expand(int id) const; void addExpand(DBaseExpand *expand, int id = -1); void setId(DBaseExpand *expand, int id); void removeExpand(DBaseExpand *expand); int checkedId() const; int id(DBaseExpand *expand) const; private: void onExpandChanged(bool v); private: QMap m_expandMap; QMap m_checkedMap; }; DWIDGET_END_NAMESPACE #endif // EXPANDGROUP_H dtkwidget-2.0.7.2/src/widgets/dfilechooseredit.cpp000066400000000000000000000063271325435343100221360ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dfilechooseredit.h" #include "dthememanager.h" #include "private/dfilechooseredit_p.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE DFileChooserEdit::DFileChooserEdit(QWidget *parent) : DLineEdit(*new DFileChooserEditPrivate(this), parent) { DThemeManager::registerWidget(this); D_D(DFileChooserEdit); d->init(); } DFileChooserEdit::DialogDisplayPosition DFileChooserEdit::dialogDisplayPosition() const { D_DC(DFileChooserEdit); return d->dialogDisplayPosition; } void DFileChooserEdit::setDialogDisplayPosition(DFileChooserEdit::DialogDisplayPosition dialogDisplayPosition) { D_D(DFileChooserEdit); d->dialogDisplayPosition = dialogDisplayPosition; } void DFileChooserEdit::setFileMode(QFileDialog::FileMode mode) { D_D(DFileChooserEdit); d->fileMode = mode; } QFileDialog::FileMode DFileChooserEdit::fileMode() const { D_DC(DFileChooserEdit); return d->fileMode; } void DFileChooserEdit::setNameFilters(const QStringList &filters) { D_D(DFileChooserEdit); d->nameFilters = filters; } QStringList DFileChooserEdit::nameFilters() const { D_DC(DFileChooserEdit); return d->nameFilters; } DFileChooserEditPrivate::DFileChooserEditPrivate(DFileChooserEdit *q) : DLineEditPrivate(q) { } void DFileChooserEditPrivate::init() { D_Q(DFileChooserEdit); q->setTextMargins(0, 0, 24, 0); q->setReadOnly(true); q->setIconVisible(true); q->connect(q, SIGNAL(iconClicked()), q, SLOT(_q_showFileChooserDialog())); } void DFileChooserEditPrivate::_q_showFileChooserDialog() { D_Q(DFileChooserEdit); QFileDialog dialog(q); dialog.setAcceptMode(QFileDialog::AcceptOpen); dialog.setFileMode(fileMode); dialog.setNameFilters(nameFilters); if (dialogDisplayPosition == DFileChooserEdit::CurrentMonitorCenter) { QPoint pos = QCursor::pos(); for (QScreen *screen : qApp->screens()) { if (screen->geometry().contains(pos)) { QRect rect = dialog.geometry(); rect.moveCenter(screen->geometry().center()); dialog.move(rect.topLeft()); } } } q->dialogOpened(); int code = dialog.exec(); if (code == QDialog::Accepted && !dialog.selectedFiles().isEmpty()) { const QString fileName = dialog.selectedFiles().first(); q->setText(fileName); Q_EMIT q->fileChoosed(fileName); } q->dialogClosed(code); } DWIDGET_END_NAMESPACE #include "moc_dfilechooseredit.cpp" dtkwidget-2.0.7.2/src/widgets/dfilechooseredit.h000066400000000000000000000035711325435343100216010ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DFILECHOOSEREDIT_H #define DFILECHOOSEREDIT_H #include "dlineedit.h" #include DWIDGET_BEGIN_NAMESPACE class DFileChooserEditPrivate; class LIBDTKWIDGETSHARED_EXPORT DFileChooserEdit : public DLineEdit { Q_OBJECT Q_ENUMS(DialogDisplayPosition) Q_PROPERTY(DialogDisplayPosition dialogDisplayPosition READ dialogDisplayPosition WRITE setDialogDisplayPosition) public: enum DialogDisplayPosition{ FoloowParentWindow, CurrentMonitorCenter }; DFileChooserEdit(QWidget *parent = nullptr); DialogDisplayPosition dialogDisplayPosition() const; void setFileMode(QFileDialog::FileMode mode); QFileDialog::FileMode fileMode() const; void setNameFilters(const QStringList &filters); QStringList nameFilters() const; public Q_SLOTS: void setDialogDisplayPosition(DialogDisplayPosition dialogDisplayPosition); Q_SIGNALS: void fileChoosed(const QString &fileName); void dialogOpened(); void dialogClosed(int code); protected: Q_DISABLE_COPY(DFileChooserEdit) D_DECLARE_PRIVATE(DFileChooserEdit) Q_PRIVATE_SLOT(d_func(), void _q_showFileChooserDialog()) }; DWIDGET_END_NAMESPACE #endif // DFILECHOOSEREDIT_H dtkwidget-2.0.7.2/src/widgets/dfiledialog.cpp000066400000000000000000000053521325435343100210620ustar00rootroot00000000000000#include "dfiledialog.h" #include #include #include #ifndef foreach #define foreach Q_FOREACH #endif #include #include DWIDGET_BEGIN_NAMESPACE DFileDialog::DFileDialog(QWidget *parent, Qt::WindowFlags f) : QFileDialog(parent, f) { } DFileDialog::DFileDialog(QWidget *parent, const QString &caption, const QString &directory, const QString &filter) : QFileDialog(parent, caption, directory, filter) { } void DFileDialog::addComboBox(const QString &text, const QStringList &data) { if (data.isEmpty()) return; addComboBox(text, DComboBoxOptions { false, data, data.first() }); } void DFileDialog::addComboBox(const QString &text, const DFileDialog::DComboBoxOptions &options) { QJsonObject json; json["text"] = text; json["editable"] = options.editable; json["data"] = QJsonArray::fromStringList(options.data); json["defaultValue"] = options.defaultValue; QStringList list = property("_dtk_widget_custom_combobox_list").toStringList(); list << QJsonDocument(json).toJson(QJsonDocument::Compact); setProperty("_dtk_widget_custom_combobox_list", list); } void DFileDialog::addLineEdit(const QString &text) { addLineEdit(text, DLineEditOptions { -1, QLineEdit::Normal, QString(), QString(), QString() }); } void DFileDialog::addLineEdit(const QString &text, const DFileDialog::DLineEditOptions &options) { QJsonObject json; json["text"] = text; json["maxLength"] = options.maxLength; json["echoMode"] = options.echoMode; json["defaultValue"] = options.defaultValue; json["inputMask"] = options.inputMask; json["placeholderText"] = options.placeholderText; QStringList list = property("_dtk_widget_custom_lineedit_list").toStringList(); list << QJsonDocument(json).toJson(QJsonDocument::Compact); setProperty("_dtk_widget_custom_lineedit_list", list); } QString DFileDialog::getComboBoxValue(const QString &text) const { return property(QString("_dtk_widget_combobox_%1_value").arg(text).toUtf8()).toString(); } QString DFileDialog::getLineEditValue(const QString &text) const { return property(QString("_dtk_widget_lineedit_%1_value").arg(text).toUtf8()).toString(); } void DFileDialog::setVisible(bool visible) { QFileDialogPrivate *d = static_cast(d_ptr.data()); if (d->canBeNativeDialog()) { QPlatformDialogHelper *helper = d->platformHelper(); if (helper) helper->setProperty("_dtk_widget_QFileDialog", reinterpret_cast(this)); } QFileDialog::setVisible(visible); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dfiledialog.h000066400000000000000000000024341325435343100205250ustar00rootroot00000000000000#ifndef DFILEDIALOG_H #define DFILEDIALOG_H #include #include #include DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DFileDialog : public QFileDialog { Q_OBJECT public: DFileDialog(QWidget *parent, Qt::WindowFlags f); explicit DFileDialog(QWidget *parent = Q_NULLPTR, const QString &caption = QString(), const QString &directory = QString(), const QString &filter = QString()); struct DComboBoxOptions { bool editable; QStringList data; QString defaultValue; }; struct DLineEditOptions { int maxLength; QLineEdit::EchoMode echoMode; QString defaultValue; QString inputMask; QString placeholderText; }; void addComboBox(const QString &text, const QStringList &data); void addComboBox(const QString &text, const DComboBoxOptions &options); void addLineEdit(const QString &text); void addLineEdit(const QString &text, const DLineEditOptions &options); QString getComboBoxValue(const QString &text) const; QString getLineEditValue(const QString &text) const; void setVisible(bool visible) override; }; DWIDGET_END_NAMESPACE #endif // DFILEDIALOG_H dtkwidget-2.0.7.2/src/widgets/dflowlayout.cpp000066400000000000000000000232661325435343100211740ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include "dflowlayout.h" #include "private/dflowlayout_p.h" DWIDGET_BEGIN_NAMESPACE DFlowLayoutPrivate::DFlowLayoutPrivate(DFlowLayout *qq) : DObjectPrivate(qq) { } QSize DFlowLayoutPrivate::doLayout(const QRect &rect, bool testOnly) const { D_QC(DFlowLayout); if(!testOnly) { if(!q->parentWidget() || q->parentWidget()->isHidden()) return QSize(); } else if(rect.width() <= 0){ return QSize(); } int left, top, right, bottom; q->getContentsMargins(&left, &top, &right, &bottom); QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom); int x = q->parentWidget()->layoutDirection() == Qt::RightToLeft ? effectiveRect.right() :effectiveRect.x(); int y = effectiveRect.y(); QSize size_hint; if(flow == DFlowLayout::Flow::LeftToRight) { int maxWidth = 0; int lineHeight = 0; if(q->parentWidget()->layoutDirection() == Qt::RightToLeft) { for (QLayoutItem *item : itemList) { int nextX = x - item->sizeHint().width() - horizontalSpacing; if (nextX + horizontalSpacing < effectiveRect.x() && lineHeight > 0) { maxWidth = qMax(effectiveRect.right() - x, maxWidth); x = effectiveRect.right(); y = y + lineHeight + verticalSpacing; nextX = x - item->sizeHint().width() - horizontalSpacing; lineHeight = 0; } if (!testOnly) { QRect item_geometry; item_geometry.setSize(item->sizeHint()); item_geometry.moveTopRight(QPoint(x, y)); item->setGeometry(item_geometry); } x = nextX; lineHeight = qMax(lineHeight, item->sizeHint().height()); } size_hint = QSize(maxWidth, y + lineHeight - rect.y() + bottom); } else { for (QLayoutItem *item : itemList) { int nextX = x + item->sizeHint().width() + horizontalSpacing; if (nextX - horizontalSpacing > effectiveRect.right() && lineHeight > 0) { maxWidth = qMax(x, maxWidth); x = effectiveRect.x(); y = y + lineHeight + verticalSpacing; nextX = x + item->sizeHint().width() + horizontalSpacing; lineHeight = 0; } if (!testOnly) item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); x = nextX; lineHeight = qMax(lineHeight, item->sizeHint().height()); } size_hint = QSize(maxWidth, y + lineHeight - rect.y() + bottom); } } else { int maxHeight = 0; int lineWidth = 0; if(q->parentWidget()->layoutDirection() == Qt::RightToLeft) { for (QLayoutItem *item : itemList) { int nextY = y + item->sizeHint().height() + verticalSpacing; if(nextY - verticalSpacing > effectiveRect.bottom() && lineWidth > 0) { maxHeight = qMax(y, maxHeight); y = effectiveRect.y(); x = x - lineWidth - horizontalSpacing; nextY = y + item->sizeHint().height() + verticalSpacing; lineWidth = 0; } if (!testOnly) item->setGeometry(QRect(QPoint(x - item->sizeHint().width(), y), item->sizeHint())); y = nextY; lineWidth = qMax(lineWidth, item->sizeHint().width()); } size_hint = QSize(rect.right() - x + lineWidth + right + 1, maxHeight); } else { for (QLayoutItem *item : itemList) { int nextY = y + item->sizeHint().height() + verticalSpacing; if(nextY - verticalSpacing > effectiveRect.bottom() && lineWidth > 0) { maxHeight = qMax(y, maxHeight); y = effectiveRect.y(); x = x + lineWidth + horizontalSpacing; nextY = y + item->sizeHint().height() + verticalSpacing; lineWidth = 0; } if (!testOnly) item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); y = nextY; lineWidth = qMax(lineWidth, item->sizeHint().width()); } size_hint = QSize(x + lineWidth - rect.x() + right, maxHeight); } } if(!testOnly) { if(sizeHint != size_hint) { sizeHint = size_hint; Q_EMIT q->sizeHintChanged(sizeHint); } } return size_hint; } DFlowLayout::DFlowLayout(QWidget *parent) : QLayout(parent), DObject(*new DFlowLayoutPrivate(this)) { } DFlowLayout::DFlowLayout() : QLayout(), DObject(*new DFlowLayoutPrivate(this)) { } DFlowLayout::~DFlowLayout() { QLayoutItem *item; while ((item = takeAt(0))) delete item; } void DFlowLayout::insertItem(int index, QLayoutItem *item) { d_func()->itemList.insert(index, item); Q_EMIT countChanged(count()); } void DFlowLayout::insertWidget(int index, QWidget *widget) { addChildWidget(widget); insertItem(index, new QWidgetItemV2(widget)); } void DFlowLayout::insertLayout(int index, QLayout *layout) { addChildLayout(layout); insertItem(index, layout); } void DFlowLayout::insertSpacing(int index, int size) { QSpacerItem *b; b = new QSpacerItem(size, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); insertSpacerItem(index, b); } void DFlowLayout::insertStretch(int index, int stretch) { Q_UNUSED(stretch); QSpacerItem *b; b = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); insertSpacerItem(index, b); } void DFlowLayout::insertSpacerItem(int index, QSpacerItem *spacerItem) { insertItem(index, spacerItem); } void DFlowLayout::addSpacing(int size) { insertSpacing(count(), size); } void DFlowLayout::addStretch(int stretch) { insertStretch(count(), stretch); } void DFlowLayout::addSpacerItem(QSpacerItem *spacerItem) { insertSpacerItem(count(), spacerItem); } void DFlowLayout::addItem(QLayoutItem *item) { insertItem(count(), item); } bool DFlowLayout::hasHeightForWidth() const { D_DC(DFlowLayout); return d->flow == DFlowLayout::Flow::LeftToRight; } int DFlowLayout::heightForWidth(int width) const { D_DC(DFlowLayout); QWidget *parentWidget = this->parentWidget(); if(parentWidget && width == parentWidget->width()) { return d->sizeHint.height(); } return d->doLayout(QRect(0, 0, width, 0), true).height(); } int DFlowLayout::count() const { return d_func()->itemList.count(); } QLayoutItem *DFlowLayout::itemAt(int index) const { return d_func()->itemList.value(index); } QSize DFlowLayout::minimumSize() const { D_DC(DFlowLayout); QSize size; for (QLayoutItem *item : d->itemList) size = size.expandedTo(item->minimumSize()); size += QSize(2 * margin(), 2 * margin()); return size; } void DFlowLayout::setGeometry(const QRect &rect) { if(rect == geometry()) return; QLayout::setGeometry(QRect(rect.topLeft(), d_func()->doLayout(rect, false))); } QSize DFlowLayout::sizeHint() const { return d_func()->sizeHint; } QLayoutItem *DFlowLayout::takeAt(int index) { D_D(DFlowLayout); if (index < 0 || index >= d->itemList.count()) { return 0; } QLayoutItem *item = d->itemList.takeAt(index); if (QLayout *l = item->layout()) { // sanity check in case the user passed something weird to QObject::setParent() if (l->parent() == this) l->setParent(0); } Q_EMIT countChanged(count()); return item; } Qt::Orientations DFlowLayout::expandingDirections() const { return Qt::Vertical; } int DFlowLayout::horizontalSpacing() const { return d_func()->horizontalSpacing; } int DFlowLayout::verticalSpacing() const { return d_func()->verticalSpacing; } DFlowLayout::Flow DFlowLayout::flow() const { D_DC(DFlowLayout); return d->flow; } void DFlowLayout::setHorizontalSpacing(int horizontalSpacing) { D_D(DFlowLayout); if(horizontalSpacing == d->horizontalSpacing) return; d->horizontalSpacing = horizontalSpacing; Q_EMIT horizontalSpacingChanged(horizontalSpacing); invalidate(); } void DFlowLayout::setVerticalSpacing(int verticalSpacing) { D_D(DFlowLayout); if(verticalSpacing == d->verticalSpacing) return; d->verticalSpacing = verticalSpacing; Q_EMIT verticalSpacingChanged(verticalSpacing); invalidate(); } void DFlowLayout::setSpacing(int spacing) { setHorizontalSpacing(spacing); setVerticalSpacing(spacing); } void DFlowLayout::setFlow(Flow direction) { D_D(DFlowLayout); if (d->flow == direction) return; d->flow = direction; Q_EMIT flowChanged(direction); invalidate(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dflowlayout.h000066400000000000000000000060661325435343100206400ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DFLOWLAYOUT_H #define DFLOWLAYOUT_H #include "dtkwidget_global.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE class DFlowLayoutPrivate; class DFlowLayout : public QLayout, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing NOTIFY horizontalSpacingChanged) Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing NOTIFY verticalSpacingChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) Q_PROPERTY(QSize sizeHint READ sizeHint NOTIFY sizeHintChanged) public: typedef QListView::Flow Flow; Q_ENUMS(Flow) explicit DFlowLayout(QWidget *parent); DFlowLayout(); ~DFlowLayout(); void insertItem(int index, QLayoutItem *item); void insertWidget(int index, QWidget *widget); void insertLayout(int index, QLayout *layout); void insertSpacing(int index, int size); void insertStretch(int index, int stretch = 0); void insertSpacerItem(int index, QSpacerItem *spacerItem); void addSpacing(int size); void addStretch(int stretch = 0); void addSpacerItem(QSpacerItem *spacerItem); void addItem(QLayoutItem *item) Q_DECL_OVERRIDE; bool hasHeightForWidth() const Q_DECL_OVERRIDE; int heightForWidth(int) const Q_DECL_OVERRIDE; int count() const Q_DECL_OVERRIDE; QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE; QSize minimumSize() const Q_DECL_OVERRIDE; void setGeometry(const QRect &rect) Q_DECL_OVERRIDE; QSize sizeHint() const Q_DECL_OVERRIDE; QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE; Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE; int horizontalSpacing() const; int verticalSpacing() const; Flow flow() const; public Q_SLOTS: void setHorizontalSpacing(int horizontalSpacing); void setVerticalSpacing(int verticalSpacing); void setSpacing(int spacing); void setFlow(Flow flow); Q_SIGNALS: void horizontalSpacingChanged(int horizontalSpacing); void verticalSpacingChanged(int verticalSpacing); void countChanged(int count); void flowChanged(Flow flow); void sizeHintChanged(QSize sizeHint) const; private: D_DECLARE_PRIVATE(DFlowLayout) }; DWIDGET_END_NAMESPACE #endif // DFLOWLAYOUT_H dtkwidget-2.0.7.2/src/widgets/dfontcombobox.cpp000066400000000000000000000070131325435343100214560ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "dfontcombobox.h" #include "private/dcombobox_p.h" DWIDGET_BEGIN_NAMESPACE class FontDelegateItem : public DComboBoxItem { Q_OBJECT public: explicit FontDelegateItem(QWidget *parent = 0); void setItemFont(const QString &family, const QString &title); }; class DComboBoxFontDelegate : public DAbstractComboBoxDelegate { public: explicit DComboBoxFontDelegate(QObject *parent = 0); QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setEditorData(QWidget *editor, const QModelIndex &index) const; }; FontDelegateItem::FontDelegateItem(QWidget *parent) : DComboBoxItem(parent) { } void FontDelegateItem::setItemFont(const QString &family, const QString &title) { QFont font = this->font(); font.setFamily(family); setFont(font); setText(title.isEmpty() ? family : title); } DComboBoxFontDelegate::DComboBoxFontDelegate(QObject *parent) : DAbstractComboBoxDelegate(parent) { } QWidget * DComboBoxFontDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(option) Q_UNUSED(index) FontDelegateItem * editor = new FontDelegateItem(parent); editor->setFixedHeight(MENU_ITEM_HEIGHT); return editor; } void DComboBoxFontDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QJsonObject dataObj = index.model()->data(index, Qt::DisplayRole).toJsonValue().toObject(); if (dataObj.isEmpty()) return; FontDelegateItem *fontItem = static_cast(editor); QString title = ""; QString family = ""; if (fontItem && dataObj.contains("itemTitle")) title = dataObj.value("itemTitle").toString(); if (fontItem && dataObj.contains("itemFontFamily")) family = dataObj.value("itemFontFamily").toString(); fontItem->setItemFont(family, title); } DFontComboBox::DFontComboBox(QWidget *parent) : DComboBox(parent) { DComboBoxFontDelegate *dbfb = new DComboBoxFontDelegate(this); setItemDelegate(dbfb); setModel(new DComboBoxModel(this)); connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChange(int))); } void DFontComboBox::addFontItem(const QString &family, const QString &title) { QJsonObject nameObj; nameObj.insert("itemFontFamily", QJsonValue(family)); nameObj.insert("itemTitle", QJsonValue(title)); dcomboBoxModel()->append(nameObj); // Make the combo boxes always displayed. view()->openPersistentEditor(dcomboBoxModel()->getModelIndex(dcomboBoxModel()->count() - 1)); } void DFontComboBox::onCurrentIndexChange(int index) { QJsonObject nameObj = dcomboBoxModel()->getJsonData(index); Q_EMIT currentFontNameChange(nameObj["itemFont"].toString()); } DWIDGET_END_NAMESPACE #include "dfontcombobox.moc" dtkwidget-2.0.7.2/src/widgets/dfontcombobox.h000066400000000000000000000026651325435343100211330ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DFONTCOMBOBOX_H #define DFONTCOMBOBOX_H #include #include #include #include #include #include #include #include #include #include "dtkwidget_global.h" #include "dcombobox.h" #include "dcomboboxmodel.h" #include "dabstractcomboboxdelegate.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DFontComboBox : public DComboBox { Q_OBJECT public: explicit DFontComboBox(QWidget *parent = 0); void addFontItem(const QString &family, const QString &title = ""); Q_SIGNALS: void currentFontNameChange(QString name); private Q_SLOTS: void onCurrentIndexChange(int index); }; DWIDGET_END_NAMESPACE #endif // DFONTCOMBOBOX_H dtkwidget-2.0.7.2/src/widgets/dforeignwindow.cpp000066400000000000000000000047221325435343100216440ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dforeignwindow.h" #include #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE #define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name // propertys DEFINE_CONST_CHAR(WmClass); DEFINE_CONST_CHAR(ProcessId); class DForeignWindowPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DForeignWindowPrivate(DForeignWindow *qq) : DObjectPrivate(qq) {} }; DForeignWindow::DForeignWindow(QWindow *parent) : QWindow(parent) , DObject(*new DForeignWindowPrivate(this)) { } DForeignWindow *DForeignWindow::fromWinId(WId id) { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ForeignWindows)) { qWarning() << "DForeignWindow::fromWinId(): platform plugin does not support foreign windows."; return 0; } DForeignWindow *window = new DForeignWindow; window->setFlags(Qt::ForeignWindow); window->setProperty("_q_foreignWinId", QVariant::fromValue(id)); window->create(); return window; } QString DForeignWindow::wmClass() const { return property(_WmClass).toString(); } quint32 DForeignWindow::pid() const { return qvariant_cast(property(_ProcessId)); } bool DForeignWindow::event(QEvent *e) { if (e->type() == QEvent::DynamicPropertyChange) { QDynamicPropertyChangeEvent *event = static_cast(e); if (event->propertyName() == _WmClass) { Q_EMIT wmClassChanged(); return true; } else if (event->propertyName() == _ProcessId) { Q_EMIT pidChanged(); return true; } } return false; } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dforeignwindow.h000066400000000000000000000026701325435343100213110ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DFOREIGNWINDOW_H #define DFOREIGNWINDOW_H #include "dobject.h" #include "dtkwidget_global.h" #include DWIDGET_BEGIN_NAMESPACE class DForeignWindowPrivate; class DForeignWindow : public QWindow, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QString wmClass READ wmClass NOTIFY wmClassChanged) Q_PROPERTY(quint32 pid READ pid NOTIFY pidChanged) public: explicit DForeignWindow(QWindow *parent = 0); static DForeignWindow *fromWinId(WId id); QString wmClass() const; quint32 pid() const; Q_SIGNALS: void wmClassChanged(); void pidChanged(); protected: bool event(QEvent *) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DForeignWindow) }; DWIDGET_END_NAMESPACE #endif // DFOREIGNWINDOW_H dtkwidget-2.0.7.2/src/widgets/dgraphicsclipeffect.cpp000066400000000000000000000057411325435343100226120ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dgraphicsclipeffect.h" #include #include #include DWIDGET_BEGIN_NAMESPACE class DGraphicsClipEffectPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DGraphicsClipEffectPrivate(DGraphicsClipEffect *qq); QPainterPath clipPath; QMargins margins; Q_DECLARE_PUBLIC(DGraphicsClipEffect) }; DGraphicsClipEffectPrivate::DGraphicsClipEffectPrivate(DGraphicsClipEffect *qq) : DObjectPrivate(qq) { } DGraphicsClipEffect::DGraphicsClipEffect(QObject *parent) : QGraphicsEffect(parent) , DObject(*new DGraphicsClipEffectPrivate(this)) { } QMargins DGraphicsClipEffect::margins() const { D_DC(DGraphicsClipEffect); return d->margins; } QPainterPath DGraphicsClipEffect::clipPath() const { D_DC(DGraphicsClipEffect); return d->clipPath; } void DGraphicsClipEffect::setMargins(const QMargins &margins) { D_D(DGraphicsClipEffect); if (d->margins == margins) return; d->margins = margins; Q_EMIT marginsChanged(margins); } void DGraphicsClipEffect::setClipPath(const QPainterPath &clipPath) { D_D(DGraphicsClipEffect); if (d->clipPath == clipPath) return; d->clipPath = clipPath; Q_EMIT clipPathChanged(clipPath); } void DGraphicsClipEffect::draw(QPainter *painter) { if (!painter->isActive()) { qWarning() << "DGraphicsClipEffect::draw: The painter is not active!"; drawSource(painter); return; } D_D(DGraphicsClipEffect); QPoint offset; Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates; QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::PadToEffectiveBoundingRect); if (pixmap.isNull()) return; QPainter pixmapPainter(&pixmap); QPainterPath newPath; newPath.addRect(pixmap.rect().marginsRemoved(d->margins)); newPath -= d->clipPath; pixmapPainter.setRenderHints(painter->renderHints() | QPainter::Antialiasing); pixmapPainter.setCompositionMode(QPainter::CompositionMode_Clear); pixmapPainter.fillPath(newPath, Qt::transparent); painter->save(); if (system == Qt::DeviceCoordinates) painter->setWorldTransform(QTransform()); painter->drawPixmap(offset, pixmap); painter->restore(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dgraphicsclipeffect.h000066400000000000000000000032551325435343100222550ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DGRAPHICSCLIPEFFECT_H #define DGRAPHICSCLIPEFFECT_H #include "dtkwidget_global.h" #include "dobject.h" #include DWIDGET_BEGIN_NAMESPACE class DGraphicsClipEffectPrivate; class DGraphicsClipEffect : public QGraphicsEffect, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QMargins margins READ margins WRITE setMargins NOTIFY marginsChanged) Q_PROPERTY(QPainterPath clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged) public: explicit DGraphicsClipEffect(QObject *parent = Q_NULLPTR); QMargins margins() const; QPainterPath clipPath() const; public Q_SLOTS: void setMargins(const QMargins &margins); void setClipPath(const QPainterPath &clipPath); Q_SIGNALS: void marginsChanged(QMargins margins); void clipPathChanged(QPainterPath clipPath); protected: void draw(QPainter *painter) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DGraphicsClipEffect) }; DWIDGET_END_NAMESPACE #endif // DGRAPHICSCLIPEFFECT_H dtkwidget-2.0.7.2/src/widgets/dgraphicsgloweffect.cpp000066400000000000000000000063371325435343100226350ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dgraphicsgloweffect.h" DWIDGET_USE_NAMESPACE DGraphicsGlowEffect::DGraphicsGlowEffect(QObject *parent) : QGraphicsEffect(parent), m_xOffset(0), m_yOffset(0), m_distance(4.0f), m_blurRadius(10.0f), m_color(0, 0, 0, 80) { } QT_BEGIN_NAMESPACE extern Q_WIDGETS_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); QT_END_NAMESPACE void DGraphicsGlowEffect::draw(QPainter *painter) { // if nothing to show outside the item, just draw source if ((blurRadius() + distance()) <= 0) { drawSource(painter); return; } PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect; QPoint offset; const QPixmap sourcePx = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); // return if no source if (sourcePx.isNull()) { return; } qreal restoreOpacity = painter->opacity(); painter->setOpacity(m_opacity); // save world transform QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); // Calculate size for the background image QSize scaleSize(sourcePx.size().width() + 2 * distance(), sourcePx.size().height() + 2 * distance()); QImage tmpImg(scaleSize, QImage::Format_ARGB32_Premultiplied); QPixmap scaled = sourcePx.scaled(scaleSize); tmpImg.fill(0); QPainter tmpPainter(&tmpImg); tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); tmpPainter.drawPixmap(QPointF(-distance(), -distance()), scaled); tmpPainter.end(); // blur the alpha channel QImage blurred(tmpImg.size(), QImage::Format_ARGB32_Premultiplied); blurred.fill(0); QPainter blurPainter(&blurred); qt_blurImage(&blurPainter, tmpImg, blurRadius(), false, true); blurPainter.end(); tmpImg = blurred; // blacken the image... tmpPainter.begin(&tmpImg); tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); tmpPainter.fillRect(tmpImg.rect(), color()); tmpPainter.end(); // draw the blurred shadow... painter->drawImage(offset, tmpImg); // draw the actual pixmap... painter->drawPixmap(offset, sourcePx, QRectF()); // restore world transform painter->setWorldTransform(restoreTransform); painter->setOpacity(restoreOpacity); } QRectF DGraphicsGlowEffect::boundingRectFor(const QRectF &rect) const { qreal delta = blurRadius() + distance(); return rect.united(rect.adjusted(-delta - xOffset(), -delta - yOffset(), delta - xOffset(), delta - yOffset())); } dtkwidget-2.0.7.2/src/widgets/dgraphicsgloweffect.h000066400000000000000000000043011325435343100222670ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DGRAPHICSGLOWEFFECT_H #define DGRAPHICSGLOWEFFECT_H #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DGraphicsGlowEffect : public QGraphicsEffect { Q_OBJECT public: explicit DGraphicsGlowEffect(QObject *parent = 0); void draw(QPainter *painter); QRectF boundingRectFor(const QRectF &rect) const; inline void setOffset(qreal dx, qreal dy) {m_xOffset = dx; m_yOffset = dy;} inline void setXOffset(qreal dx) {m_xOffset = dx;} inline qreal xOffset() const {return m_xOffset;} inline void setYOffset(qreal dy) {m_yOffset = dy;} inline qreal yOffset() const {return m_yOffset;} inline void setDistance(qreal distance) { m_distance = distance; updateBoundingRect(); } inline qreal distance() const { return m_distance; } inline void setBlurRadius(qreal blurRadius) { m_blurRadius = blurRadius; updateBoundingRect(); } inline qreal blurRadius() const { return m_blurRadius; } inline void setColor(const QColor &color) { m_color = color; } inline QColor color() const { return m_color; } // TODO: refactor with d-pointer; inline qreal opacity() const { return m_opacity; } inline void setOpacity(qreal opacity) { m_opacity = opacity; } private: qreal m_opacity = 1.0; qreal m_xOffset; qreal m_yOffset; qreal m_distance; qreal m_blurRadius; QColor m_color; }; DWIDGET_END_NAMESPACE #endif // DGRAPHICSGLOWEFFECT_H dtkwidget-2.0.7.2/src/widgets/dheaderline.cpp000066400000000000000000000026301325435343100210570ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dheaderline.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE DHeaderLine::DHeaderLine(QWidget *parent) : DBaseLine(parent) { DThemeManager::registerWidget(this); setAlignment(Qt::AlignVCenter | Qt::AlignLeft); setFixedHeight(EXPAND_HEADER_HEIGHT); m_titleLabel = new QLabel(this); m_titleLabel->setObjectName("DHeaderLineTitle"); DBaseLine::setLeftContent(m_titleLabel); } void DHeaderLine::setTitle(const QString &title) { m_titleLabel->setText(title); } void DHeaderLine::setContent(QWidget *content) { DBaseLine::setRightContent(content); setFixedHeight(CONTENT_HEADER_HEIGHT); } QString DHeaderLine::title() const { return m_titleLabel->text(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dheaderline.h000066400000000000000000000024131325435343100205230ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DHEADERLINE_H #define DHEADERLINE_H #include #include #include "dtkwidget_global.h" #include "dbaseline.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DHeaderLine : public DBaseLine { Q_OBJECT public: explicit DHeaderLine(QWidget *parent = 0); void setTitle(const QString &title); void setContent(QWidget *content); QString title() const; private: void setLeftContent(QWidget *content); void setRightContent(QWidget *content); private: QLabel *m_titleLabel = NULL; }; DWIDGET_END_NAMESPACE #endif // DHEADERLINE_H dtkwidget-2.0.7.2/src/widgets/dialog_constants.h000066400000000000000000000030541325435343100216140ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef BUTTON_CONSTANTS_H #define BUTTON_CONSTANTS_H #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE namespace DIALOG { const int DEFAULT_WIDTH = 380; const int DEFAULT_HEIGHT = 120; const int BORDER_SHADOW_WIDTH = 0; const int BORDER_RADIUS = 4; const int CONTENT_INSERT_OFFSET = 2; const int BUTTON_HEIGHT = 28; const int CLOSE_BUTTON_WIDTH = 27; const int CLOSE_BUTTON_HEIGHT = 23; const int ICON_LAYOUT_TOP_MARGIN = 14; const int ICON_LAYOUT_BOTTOM_MARGIN = 14; const int ICON_LAYOUT_LEFT_MARGIN = 20; const int ICON_LAYOUT_RIGHT_MARGIN = 20; const int ICON_LAYOUT_SPACING = 20; const int BUTTON_LAYOUT_TOP_MARGIN = 0; const int BUTTON_LAYOUT_BOTTOM_MARGIN = 0; const int BUTTON_LAYOUT_LEFT_MARGIN = 0; const int BUTTON_LAYOUT_RIGHT_MARGIN = 0; } DWIDGET_END_NAMESPACE #endif // BUTTON_CONSTANTS_H dtkwidget-2.0.7.2/src/widgets/dialogs.pri000066400000000000000000000017601325435343100202500ustar00rootroot00000000000000HEADERS += \ $$PWD/dabstractdialog.h \ $$PWD/ddialog.h \ $$PWD/dialog_constants.h \ $$PWD/dinputdialog.h \ $$PWD/daboutdialog.h \ $$PWD/dsettingsdialog.h \ $$PWD/private/settings/buttongroup.h \ $$PWD/private/settings/combobox.h \ $$PWD/private/settings/content.h \ $$PWD/private/settings/contenttitle.h \ $$PWD/private/settings/navigation.h \ $$PWD/private/settings/navigationdelegate.h \ $$PWD/private/settings/shortcutedit.h \ $$PWD/dfiledialog.h SOURCES += \ $$PWD/dabstractdialog.cpp \ $$PWD/ddialog.cpp \ $$PWD/dinputdialog.cpp \ $$PWD/daboutdialog.cpp \ $$PWD/dsettingsdialog.cpp \ $$PWD/private/settings/buttongroup.cpp \ $$PWD/private/settings/combobox.cpp \ $$PWD/private/settings/content.cpp \ $$PWD/private/settings/contenttitle.cpp \ $$PWD/private/settings/navigation.cpp \ $$PWD/private/settings/navigationdelegate.cpp \ $$PWD/private/settings/shortcutedit.cpp \ $$PWD/dfiledialog.cpp dtkwidget-2.0.7.2/src/widgets/dimagebutton.cpp000066400000000000000000000251351325435343100213020ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dimagebutton.h" #include "dconstants.h" #include "dthememanager.h" #include "private/dimagebutton_p.h" #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE /*! * \class DImageButton * \brief The DImageButton class provides an easy way to create image based buttons. * * A DImageButton has four states: normal, hover, pressed and checked, developers * should provide at least the normal state image to get it to work properly. */ /*! * \brief DImageButton::DImageButton constructs an instance of DImageButton * \param parent is the parent widget that the button will be attached to. */ DImageButton::DImageButton(QWidget *parent) : QLabel(parent) , DObject(*new DImageButtonPrivate(this)) { DThemeManager::registerWidget(this, QStringList({"checked", "state"})); D_D(DImageButton); d->updateIcon(); } /*! * \brief DImageButton::DImageButton This is an overloaded function. * * It's convinient to provide the images that used at the initialize stage. * * \param normalPic is the path of image to be used as the normal state. * \param hoverPic is the path of image to be used as the hover state. * \param pressPic is the path of image to be used as the pressed state. * \param parent is the parent widget that the button will be attached to. */ DImageButton::DImageButton(const QString &normalPic, const QString &hoverPic, const QString &pressPic, QWidget *parent) : QLabel(parent) , DObject(*new DImageButtonPrivate(this)) { DThemeManager::registerWidget(this, QStringList({"checked", "state"})); D_D(DImageButton); if (!normalPic.isEmpty()) { d->m_normalPic = normalPic; } if (!hoverPic.isEmpty()) { d->m_hoverPic = hoverPic; } if (!pressPic.isEmpty()) { d->m_pressPic = pressPic; } setCheckable(false); d->updateIcon(); } /*! * \brief DImageButton::DImageButton This is an overloaded function. * * It's convinient to provide the images that used at the initialize stage. * * \param normalPic is the path of image to be used as the normal state. * \param hoverPic is the path of image to be used as the hover state. * \param pressPic is the path of image to be used as the pressed state. * \param checkedPic is the path of image to be used as the checked state. * \param parent is the parent widget that the button will be attached to. */ DImageButton::DImageButton(const QString &normalPic, const QString &hoverPic, const QString &pressPic, const QString &checkedPic, QWidget *parent) : QLabel(parent) , DObject(*new DImageButtonPrivate(this)) { DThemeManager::registerWidget(this, QStringList({"checked", "state"})); D_D(DImageButton); if (!normalPic.isEmpty()) { d->m_normalPic = normalPic; } if (!hoverPic.isEmpty()) { d->m_hoverPic = hoverPic; } if (!pressPic.isEmpty()) { d->m_pressPic = pressPic; } if (!checkedPic.isEmpty()) { d->m_checkedPic = checkedPic; } setCheckable(true); d->updateIcon(); } DImageButton::~DImageButton() { } void DImageButton::enterEvent(QEvent *event) { D_D(DImageButton); setCursor(Qt::PointingHandCursor); if (!d->m_isChecked && isEnabled()) { d->setState(Hover); } event->accept(); //QLabel::enterEvent(event); } void DImageButton::leaveEvent(QEvent *event) { D_D(DImageButton); if (!d->m_isChecked && isEnabled()) { d->setState(Normal); } event->accept(); //QLabel::leaveEvent(event); } void DImageButton::mousePressEvent(QMouseEvent *event) { D_D(DImageButton); if (event->button() != Qt::LeftButton) { return; } d->setState(Press); event->accept(); //QLabel::mousePressEvent(event); } void DImageButton::mouseReleaseEvent(QMouseEvent *event) { D_D(DImageButton); event->accept(); if (event->button() != Qt::LeftButton) { return; } if (!rect().contains(event->pos())) { return; } if (d->m_isCheckable) { d->m_isChecked = !d->m_isChecked; if (d->m_isChecked) { d->setState(Checked); } else { d->setState(Normal); } } else { d->setState(Hover); } Q_EMIT clicked(); } void DImageButton::mouseMoveEvent(QMouseEvent *event) { D_D(DImageButton); if (!d->m_isCheckable && !rect().contains(event->pos())) { d->setState(Normal); } } void DImageButton::setEnabled(bool enabled) { D_D(DImageButton); if (!enabled) { d->setState(Disabled); } else { d->setState(Normal); } QWidget::setEnabled(enabled); } void DImageButton::setDisabled(bool disabled) { setEnabled(!disabled); } void DImageButton::setCheckable(bool flag) { D_D(DImageButton); d->m_isCheckable = flag; if (!d->m_isCheckable) { d->setState(Normal); } } void DImageButton::setChecked(bool flag) { D_D(DImageButton); if (d->m_isCheckable == false) { return; } d->m_isChecked = flag; if (d->m_isChecked) { d->setState(Checked); } else { d->setState(Normal); } Q_EMIT checkedChanged(d->m_isChecked); } /*! * \property DImageButton::checked * \brief This property indicates the DImageButton is in checked state of not. */ bool DImageButton::isChecked() const { D_DC(DImageButton); return d->m_isChecked; } /*! * \property DImageButton::isCheckable * \brief This property indicates the DImageButton can be checked or not. */ bool DImageButton::isCheckable() const { D_DC(DImageButton); return d->m_isCheckable; } void DImageButton::setNormalPic(const QString &normalPicPixmap) { D_D(DImageButton); d->m_normalPic = normalPicPixmap; d->updateIcon(); } void DImageButton::setHoverPic(const QString &hoverPicPixmap) { D_D(DImageButton); d->m_hoverPic = hoverPicPixmap; d->updateIcon(); } void DImageButton::setPressPic(const QString &pressPicPixmap) { D_D(DImageButton); d->m_pressPic = pressPicPixmap; d->updateIcon(); } void DImageButton::setCheckedPic(const QString &checkedPicPixmap) { D_D(DImageButton); d->m_checkedPic = checkedPicPixmap; d->updateIcon(); } void DImageButton::setDisabledPic(const QString &disabledPicPixmap) { D_D(DImageButton); d->m_disabledPic = disabledPicPixmap; d->updateIcon(); } /*! * \property DImageButton::getNormalPic * \brief This property holds the path of the image used as the normal state. */ const QString DImageButton::getNormalPic() const { D_DC(DImageButton); return d->m_normalPic; } /*! * \property DImageButton::getHoverPic * \brief This property holds the path of the image used as the hover state. */ const QString DImageButton::getHoverPic() const { D_DC(DImageButton); return d->m_hoverPic; } /*! * \property DImageButton::getPressPic * \brief This property holds the path of the image used as the pressed state. */ const QString DImageButton::getPressPic() const { D_DC(DImageButton); return d->m_pressPic; } /*! * \property DImageButton::getCheckedPic * \brief This property holds the path of the image used as the checked state. */ const QString DImageButton::getCheckedPic() const { D_DC(DImageButton); return d->m_checkedPic; } const QString DImageButton::getDisabledPic() const { D_DC(DImageButton); return d->m_disabledPic; } /*! * \brief DImageButton::setState change the image by state * \param state: see DImageButton::State */ void DImageButton::setState(DImageButton::State state) { D_D(DImageButton); d->setState(state); } /*! * \brief DImageButton::getState * \return the state that the DImageButton is in. */ DImageButton::State DImageButton::getState() const { D_DC(DImageButton); return d->m_state; } DImageButton::DImageButton(DImageButtonPrivate &q, QWidget *parent) : QLabel(parent) , DObject(q) { DThemeManager::registerWidget(this, QStringList({"checked", "state"})); D_D(DImageButton); d->updateIcon(); } DImageButtonPrivate::DImageButtonPrivate(DImageButton *qq) : DObjectPrivate(qq) { } DImageButtonPrivate::~DImageButtonPrivate() { } void DImageButtonPrivate::updateIcon() { D_Q(DImageButton); switch (m_state) { case DImageButton::Hover: q->setProperty("state", "hover"); if (!m_hoverPic.isEmpty()) { q->setPixmap(loadPixmap(m_hoverPic)); } break; case DImageButton::Press: q->setProperty("state", "press"); if (!m_pressPic.isEmpty()) { q->setPixmap(loadPixmap(m_pressPic)); } break; case DImageButton::Checked: q->setProperty("state", "checked"); if (!m_checkedPic.isEmpty()) { q->setPixmap(loadPixmap(m_checkedPic)); } break; case DImageButton::Disabled: q->setProperty("state", "disabled"); if (!m_disabledPic.isEmpty()) { q->setPixmap(loadPixmap(m_disabledPic)); } break; default: q->setProperty("state", ""); if (!m_normalPic.isEmpty()) { q->setPixmap(loadPixmap(m_normalPic)); } break; } q->setAlignment(Qt::AlignCenter); Q_EMIT q->stateChanged(); } void DImageButtonPrivate::setState(DImageButton::State state) { if (m_state == state) { return; } m_state = state; updateIcon(); } QPixmap DImageButtonPrivate::loadPixmap(const QString &path) { D_Q(DImageButton); qreal ratio = 1.0; const qreal devicePixelRatio = q->devicePixelRatioF(); QPixmap pixmap; if (!qFuzzyCompare(ratio, devicePixelRatio)) { QImageReader reader; reader.setFileName(qt_findAtNxFile(path, devicePixelRatio, &ratio)); if (reader.canRead()) { reader.setScaledSize(reader.size() * (devicePixelRatio / ratio)); pixmap = QPixmap::fromImage(reader.read()); pixmap.setDevicePixelRatio(devicePixelRatio); } } else { pixmap.load(path); } return pixmap; } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dimagebutton.h000066400000000000000000000070101325435343100207370ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DIMAGEBUTTON_H #define DIMAGEBUTTON_H #include #include #include #include #include "dtkwidget_global.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE class DImageButtonPrivate; class LIBDTKWIDGETSHARED_EXPORT DImageButton : public QLabel, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QString normalPic READ getNormalPic WRITE setNormalPic DESIGNABLE true) Q_PROPERTY(QString hoverPic READ getHoverPic WRITE setHoverPic DESIGNABLE true) Q_PROPERTY(QString pressPic READ getPressPic WRITE setPressPic DESIGNABLE true) Q_PROPERTY(QString checkedPic READ getCheckedPic WRITE setCheckedPic DESIGNABLE true) Q_PROPERTY(QString disabledPic READ getDisabledPic WRITE setDisabledPic DESIGNABLE true) Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable) public: DImageButton(QWidget *parent = 0); DImageButton(const QString &normalPic, const QString &hoverPic, const QString &pressPic, QWidget *parent = 0); DImageButton(const QString &normalPic, const QString &hoverPic, const QString &pressPic, const QString &checkedPic, QWidget *parent = 0); ~DImageButton(); void setEnabled(bool enabled); void setDisabled(bool disabled); void setChecked(bool flag); void setCheckable(bool flag); bool isChecked() const; bool isCheckable() const; void setNormalPic(const QString &normalPic); void setHoverPic(const QString &hoverPic); void setPressPic(const QString &pressPic); void setCheckedPic(const QString &checkedPic); void setDisabledPic(const QString &disabledPic); const QString getNormalPic() const; const QString getHoverPic() const; const QString getPressPic() const; const QString getCheckedPic() const; const QString getDisabledPic() const; /*! * \brief The State enum contains the four possible states of DImageButton. */ enum State { Normal, /*!< normal state */ Hover, /*!< hover state */ Press, /*!< pressed state */ Checked,/*!< checked state */ Disabled /*!< disabled state */ }; void setState(State state); State getState() const; Q_SIGNALS: void clicked(); void checkedChanged(bool checked); void stateChanged(); protected: DImageButton(DImageButtonPrivate &q, QWidget *parent); void enterEvent(QEvent *event) Q_DECL_OVERRIDE; void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(DImageButton) D_DECLARE_PRIVATE(DImageButton) }; DWIDGET_END_NAMESPACE #endif // DIMAGEBUTTON_H dtkwidget-2.0.7.2/src/widgets/dinputdialog.cpp000066400000000000000000000273101325435343100213000ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "dinputdialog.h" #include "private/dinputdialog_p.h" #include "dspinbox.h" #include "dcombobox.h" #include "dlabel.h" #include "dpasswordedit.h" DWIDGET_BEGIN_NAMESPACE DInputDialogPrivate::DInputDialogPrivate(DInputDialog *qq) : DDialogPrivate(qq) { } void DInputDialogPrivate::init() { D_Q(DInputDialog); q->addButtons(QStringList() << QApplication::translate("DInputDialog", "Cancel") << QApplication::translate("DInputDialog", "Confirm")); q->setOnButtonClickedClose(false); q->setDefaultButton(1); cancelButton = q->getButton(0); okButton = q->getButton(1); lineEdit = new DLineEdit; spinBox = new DSpinBox; doubleSpinBox = new DDoubleSpinBox; comboBox = new DComboBox; q->addSpacing(10); q->addContent(lineEdit); q->addContent(spinBox); q->addContent(doubleSpinBox); q->addContent(comboBox); q->setInputMode(DInputDialog::TextInput); q->connect(lineEdit, &DLineEdit::textChanged, q, &DInputDialog::textValueChanged); q->connect(lineEdit, &DLineEdit::alertChanged, q, &DInputDialog::textAlertChanged); q->connect(comboBox, &DComboBox::currentTextChanged, q, &DInputDialog::textValueChanged); q->connect(comboBox, SIGNAL(currentTextChanged(QString)), q, SIGNAL(textValueChanged(QString))); q->connect(spinBox, SIGNAL(valueChanged(int)), q, SIGNAL(intValueChanged(int))); q->connect(doubleSpinBox, SIGNAL(valueChanged(double)), q, SIGNAL(doubleValueChanged(double))); q->connect(cancelButton, &QAbstractButton::clicked, q, [q] { q->done(QDialog::Rejected); q->cancelButtonClicked(); }); q->connect(okButton, &QAbstractButton::clicked, q, [q, this] { q->done(QDialog::Accepted); q->okButtonClicked(); switch (inputMode) { case DInputDialog::TextInput: q->textValueSelected(lineEdit->text()); break; case DInputDialog::ComboBox: q->textValueSelected(comboBox->currentText()); break; case DInputDialog::IntInput: q->intValueSelected(spinBox->value()); break; case DInputDialog::DoubleInput: q->doubleValueSelected(doubleSpinBox->value()); break; default: break; } }); } DInputDialog::DInputDialog(QWidget *parent) : DDialog(*new DInputDialogPrivate(this), parent) { d_func()->init(); } void DInputDialog::setInputMode(DInputDialog::InputMode mode) { D_D(DInputDialog); d->inputMode = mode; switch (mode) { case InputMode::TextInput: d->lineEdit->show(); d->comboBox->hide(); d->spinBox->hide(); d->doubleSpinBox->hide(); break; case InputMode::ComboBox: d->comboBox->show(); d->lineEdit->hide(); d->spinBox->hide(); d->doubleSpinBox->hide(); break; case InputMode::IntInput: d->spinBox->show(); d->lineEdit->hide(); d->comboBox->hide(); d->doubleSpinBox->hide(); break; case InputMode::DoubleInput: d->doubleSpinBox->show(); d->lineEdit->hide(); d->comboBox->hide(); d->spinBox->hide(); break; default: break; } } DInputDialog::InputMode DInputDialog::inputMode() const { D_DC(DInputDialog); return d->inputMode; } void DInputDialog::setTextValue(const QString &text) { D_D(DInputDialog); if(inputMode() == ComboBox) d->comboBox->setCurrentText(text); else d->lineEdit->setText(text); } QString DInputDialog::textValue() const { D_DC(DInputDialog); return inputMode() == ComboBox ? d->comboBox->currentText() : d->lineEdit->text(); } void DInputDialog::setTextEchoMode(QLineEdit::EchoMode mode) { D_D(DInputDialog); if(mode == d->lineEdit->echoMode()) return; DLineEdit *edit; if(mode == DLineEdit::Normal) { edit = new DLineEdit; } else { edit = new DPasswordEdit; edit->setEchoMode(mode); } disconnect(d->lineEdit, &DLineEdit::alertChanged, this, &DInputDialog::textAlertChanged); disconnect(d->lineEdit, &DLineEdit::textChanged, this, &DInputDialog::textValueChanged); connect(edit, &DLineEdit::alertChanged, this, &DInputDialog::textAlertChanged); connect(edit, &DLineEdit::textChanged, this, &DInputDialog::textValueChanged); edit->setText(d->lineEdit->text()); insertContent(d->getContentLayout()->indexOf(d->lineEdit), edit); removeContent(d->lineEdit); d->lineEdit = edit; } QLineEdit::EchoMode DInputDialog::textEchoMode() const { D_DC(DInputDialog); return d->lineEdit->echoMode(); } void DInputDialog::setComboBoxEditable(bool editable) { D_D(DInputDialog); d->comboBox->setEditable(editable); if (editable) connect(d->comboBox->lineEdit(), &QLineEdit::textChanged, this, &DInputDialog::textValueChanged, Qt::UniqueConnection); } bool DInputDialog::isComboBoxEditable() const { D_DC(DInputDialog); return d->comboBox->isEditable(); } void DInputDialog::setComboBoxItems(const QStringList &items) { D_D(DInputDialog); d->comboBox->clear(); d->comboBox->addItems(items); } QStringList DInputDialog::comboBoxItems() const { D_DC(DInputDialog); QStringList list; for(int i = 0; i < d->comboBox->count(); ++i) { list << d->comboBox->itemText(i); } return list; } int DInputDialog::comboBoxCurrentIndex() const { D_DC(DInputDialog); return d->comboBox->currentIndex(); } void DInputDialog::setComboBoxCurrentIndex(int comboBoxCurrentIndex) { D_D(DInputDialog); d->comboBox->setCurrentIndex(comboBoxCurrentIndex); } void DInputDialog::setIntValue(int value) { D_DC(DInputDialog); d->spinBox->setValue(value); } int DInputDialog::intValue() const { D_DC(DInputDialog); return d->spinBox->value(); } void DInputDialog::setIntMinimum(int min) { D_D(DInputDialog); d->spinBox->setMinimum(min); } int DInputDialog::intMinimum() const { D_DC(DInputDialog); return d->spinBox->minimum(); } void DInputDialog::setIntMaximum(int max) { D_D(DInputDialog); d->spinBox->setMaximum(max); } int DInputDialog::intMaximum() const { D_DC(DInputDialog); return d->spinBox->maximum(); } void DInputDialog::setIntRange(int min, int max) { D_D(DInputDialog); d->spinBox->setRange(min, max); } void DInputDialog::setIntStep(int step) { D_D(DInputDialog); d->spinBox->setSingleStep(step); } int DInputDialog::intStep() const { D_DC(DInputDialog); return d->spinBox->singleStep(); } void DInputDialog::setDoubleValue(double value) { D_D(DInputDialog); d->doubleSpinBox->setValue(value); } double DInputDialog::doubleValue() const { D_DC(DInputDialog); return d->doubleSpinBox->value(); } void DInputDialog::setDoubleMinimum(double min) { D_D(DInputDialog); d->doubleSpinBox->setMinimum(min); } double DInputDialog::doubleMinimum() const { D_DC(DInputDialog); return d->doubleSpinBox->minimum(); } void DInputDialog::setDoubleMaximum(double max) { D_D(DInputDialog); d->doubleSpinBox->setMaximum(max); } double DInputDialog::doubleMaximum() const { D_DC(DInputDialog); return d->doubleSpinBox->maximum(); } void DInputDialog::setDoubleRange(double min, double max) { D_D(DInputDialog); d->doubleSpinBox->setRange(min, max); } void DInputDialog::setDoubleDecimals(int decimals) { D_D(DInputDialog); d->doubleSpinBox->setDecimals(decimals); } int DInputDialog::doubleDecimals() const { D_DC(DInputDialog); return d->doubleSpinBox->decimals(); } void DInputDialog::setOkButtonText(const QString &text) { D_DC(DInputDialog); d->okButton->setText(text); } QString DInputDialog::okButtonText() const { D_DC(DInputDialog); return d->okButton->text(); } void DInputDialog::setOkButtonEnabled(const bool enable) { D_DC(DInputDialog); d->okButton->setEnabled(enable); } bool DInputDialog::okButtonIsEnabled() const { D_DC(DInputDialog); return d->okButton->isEnabled(); } void DInputDialog::setCancelButtonText(const QString &text) { D_DC(DInputDialog); d->cancelButton->setText(text); } QString DInputDialog::cancelButtonText() const { D_DC(DInputDialog); return d->cancelButton->text(); } void DInputDialog::setTextAlert(bool textAlert) { D_D(DInputDialog); d->lineEdit->setAlert(textAlert); } bool DInputDialog::isTextAlert() const { D_DC(DInputDialog); return d->lineEdit->isAlert(); } QString DInputDialog::getText(QWidget *parent, const QString &title, const QString &message, QLineEdit::EchoMode echo, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { DInputDialog dialog(parent); dialog.setTitle(title); dialog.setMessage(message); dialog.setTextEchoMode(echo); dialog.setTextValue(text); dialog.setWindowFlags(flags); dialog.setInputMethodHints(inputMethodHints); *ok = dialog.exec() == QDialog::Accepted; return dialog.textValue(); } QString DInputDialog::getItem(QWidget *parent, const QString &title, const QString &message, const QStringList &items, int current, bool editable, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { DInputDialog dialog(parent); dialog.setComboBoxItems(items); dialog.setComboBoxEditable(editable); dialog.setComboBoxCurrentIndex(current); dialog.setTitle(title); dialog.setMessage(message); dialog.setWindowFlags(flags); dialog.setInputMethodHints(inputMethodHints); *ok = dialog.exec() == QDialog::Accepted; return dialog.textValue(); } int DInputDialog::getInt(QWidget *parent, const QString &title, const QString &message, int value, int minValue, int maxValue, int step, bool *ok, Qt::WindowFlags flags) { DInputDialog dialog(parent); dialog.setIntValue(value); dialog.setIntRange(minValue, maxValue); dialog.setIntStep(step); dialog.setTitle(title); dialog.setMessage(message); dialog.setWindowFlags(flags); *ok = dialog.exec() == QDialog::Accepted; return dialog.intValue(); } double DInputDialog::getDouble(QWidget *parent, const QString &title, const QString &message, double value, double minValue, double maxValue, int decimals, bool *ok, Qt::WindowFlags flags) { DInputDialog dialog(parent); dialog.setDoubleValue(value); dialog.setDoubleRange(minValue, maxValue); dialog.setDoubleDecimals(decimals); dialog.setTitle(title); dialog.setMessage(message); dialog.setWindowFlags(flags); *ok = dialog.exec() == QDialog::Accepted; return dialog.doubleValue(); } void DInputDialog::showEvent(QShowEvent *e) { DDialog::showEvent(e); Q_D(DInputDialog); d->lineEdit->setFocus(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dinputdialog.h000066400000000000000000000135201325435343100207430ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DINPUTDIALOG_H #define DINPUTDIALOG_H #include #include "ddialog.h" #include "dlineedit.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE class DInputDialogPrivate; class DInputDialog : public DDialog { Q_OBJECT Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode) Q_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged) Q_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged) Q_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged) Q_PROPERTY(DLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode) Q_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable) Q_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems) Q_PROPERTY(int comboBoxCurrentIndex READ comboBoxCurrentIndex WRITE setComboBoxCurrentIndex NOTIFY comboBoxCurrentIndexChanged) Q_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum) Q_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum) Q_PROPERTY(int intStep READ intStep WRITE setIntStep) Q_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum) Q_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum) Q_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals) Q_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText) Q_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText) Q_PROPERTY(bool textAlert READ isTextAlert WRITE setTextAlert NOTIFY textAlertChanged) public: enum InputMode { TextInput, ComboBox, IntInput, DoubleInput }; explicit DInputDialog(QWidget *parent = 0); Q_SLOT void setInputMode(InputMode mode); InputMode inputMode() const; Q_SLOT void setTextValue(const QString &text); QString textValue() const; Q_SLOT void setTextEchoMode(QLineEdit::EchoMode mode); QLineEdit::EchoMode textEchoMode() const; Q_SLOT void setComboBoxEditable(bool editable); bool isComboBoxEditable() const; Q_SLOT void setComboBoxItems(const QStringList &items); QStringList comboBoxItems() const; Q_SLOT void setComboBoxCurrentIndex(int comboBoxCurrentIndex); int comboBoxCurrentIndex() const; Q_SLOT void setIntValue(int value); int intValue() const; Q_SLOT void setIntMinimum(int min); int intMinimum() const; Q_SLOT void setIntMaximum(int max); int intMaximum() const; Q_SLOT void setIntRange(int min, int max); Q_SLOT void setIntStep(int step); int intStep() const; Q_SLOT void setDoubleValue(double value); double doubleValue() const; Q_SLOT void setDoubleMinimum(double min); double doubleMinimum() const; Q_SLOT void setDoubleMaximum(double max); double doubleMaximum() const; Q_SLOT void setDoubleRange(double min, double max); Q_SLOT void setDoubleDecimals(int decimals); int doubleDecimals() const; Q_SLOT void setOkButtonText(const QString &text); QString okButtonText() const; Q_SLOT void setOkButtonEnabled(const bool enable); bool okButtonIsEnabled() const; Q_SLOT void setCancelButtonText(const QString &text); QString cancelButtonText() const; Q_SLOT void setTextAlert(bool textAlert); bool isTextAlert() const; static QString getText(QWidget *parent, const QString &title, const QString &message, QLineEdit::EchoMode echo = QLineEdit::Normal, const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone); static QString getItem(QWidget *parent, const QString &title, const QString &message, const QStringList &items, int current = 0, bool editable = true, bool *ok = 0, Qt::WindowFlags flags = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone); static int getInt(QWidget *parent, const QString &title, const QString &message, int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0); static double getDouble(QWidget *parent, const QString &title, const QString &message, double value = 0, double minValue = -2147483647, double maxValue = 2147483647, int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = 0); protected: void showEvent(QShowEvent *e); Q_SIGNALS: // ### Q_EMIT signals! void textValueChanged(const QString &text); void textValueSelected(const QString &text); void intValueChanged(int value); void intValueSelected(int value); void doubleValueChanged(double value); void doubleValueSelected(double value); void cancelButtonClicked(); void okButtonClicked(); void comboBoxCurrentIndexChanged(int comboBoxCurrentIndex); void textAlertChanged(bool textAlert); private: D_DECLARE_PRIVATE(DInputDialog) }; DWIDGET_END_NAMESPACE #endif // DINPUTDIALOG_H dtkwidget-2.0.7.2/src/widgets/dinputdialog_p.h000066400000000000000000000014101325435343100212550ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DINPUTDIALOG_P_H #define DINPUTDIALOG_P_H #endif // DINPUTDIALOG_P_H dtkwidget-2.0.7.2/src/widgets/dipv4lineedit.cpp000066400000000000000000000271721325435343100213670ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include "dthememanager.h" #include "dipv4lineedit.h" #include "private/dipv4lineedit_p.h" DWIDGET_BEGIN_NAMESPACE #define RX_PATTERN_IP "^(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)?$" DIpv4LineEditPrivate::DIpv4LineEditPrivate(DIpv4LineEdit *parent) : DLineEditPrivate(parent) { } void DIpv4LineEditPrivate::init() { D_Q(DIpv4LineEdit); editMainWidget = new QWidget(q); QHBoxLayout *hbox_layout = new QHBoxLayout; hbox_layout->setSpacing(0); hbox_layout->setMargin(0); hbox_layout->addWidget(getEdit()); hbox_layout->addWidget(getLabel()); hbox_layout->addWidget(getEdit()); hbox_layout->addWidget(getLabel()); hbox_layout->addWidget(getEdit()); hbox_layout->addWidget(getLabel()); hbox_layout->addWidget(getEdit()); editMainWidget->setLayout(hbox_layout); q->DLineEdit::setReadOnly(true); q->setFocusProxy(editList.first()); q->setValidator(new QRegularExpressionValidator(QRegularExpression("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)?\\.){0,3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)?"), q)); QObject::connect(q, &DIpv4LineEdit::sizeChanged, editMainWidget, static_cast(&QWidget::resize)); QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_setIpLineEditText(QString)), Qt::QueuedConnection); } QLabel *DIpv4LineEditPrivate::getLabel() { QLabel *label = new QLabel("."); label->setObjectName("DIpv4LineEdit_Label"); label->setCursor(Qt::IBeamCursor); return label; } QLineEdit *DIpv4LineEditPrivate::getEdit() { D_Q(DIpv4LineEdit); QLineEdit *edit = new QLineEdit; edit->setObjectName("DIpv4LineEdit_Edit"); edit->setValidator(new QRegularExpressionValidator(QRegularExpression(RX_PATTERN_IP), edit)); edit->setAlignment(Qt::AlignHCenter); edit->setAttribute(Qt::WA_InputMethodEnabled, false); edit->setContextMenuPolicy(Qt::NoContextMenu); edit->installEventFilter(q); editList << edit; QObject::connect(edit, SIGNAL(textEdited(QString)), q, SLOT(_q_updateLineEditText())); return edit; } void DIpv4LineEditPrivate::setFocus(bool focus) { if(this->focus == focus) return; this->focus = focus; Q_EMIT q_func()->focusChanged(focus); } void DIpv4LineEditPrivate::_q_updateLineEditText() { D_Q(DIpv4LineEdit); QString text; for(const QLineEdit *edit : editList) { text.append(".").append(edit->text()); } QObject::disconnect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_setIpLineEditText(QString))); if(text == "....") { if(!q->text().isEmpty()) { q->setText(""); Q_EMIT q->textEdited(q->text()); } } else { text = text.mid(1); if(text != q->text()) { q->setText(text); Q_EMIT q->textEdited(q->text()); } } QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_setIpLineEditText(QString)), Qt::QueuedConnection); q->DLineEdit::setCursorPosition(q->cursorPosition()); } void DIpv4LineEditPrivate::_q_setIpLineEditText(const QString &text) { D_QC(DIpv4LineEdit); int pos = 0; if(q->validator()->validate(const_cast(text), pos) != QValidator::Acceptable) { _q_updateLineEditText(); return; } const QStringList text_list = text.split('.'); int min_count = qMin(editList.count(), text_list.count()); for(int i = 0; i < min_count; ++i ) { QLineEdit *edit = editList[i]; bool edit_blocked = edit->blockSignals(true); edit->setText(text_list[i]); edit->blockSignals(edit_blocked); } for(int i = min_count; i < editList.count(); ++i) { QLineEdit *edit = editList[i]; bool edit_blocked = edit->blockSignals(true); edit->clear(); edit->blockSignals(edit_blocked); } } DIpv4LineEdit::DIpv4LineEdit(QWidget *parent) : DLineEdit(*new DIpv4LineEditPrivate(this), parent) { DThemeManager::registerWidget(this); d_func()->init(); } QString DIpv4LineEdit::displayText() const { return text(); } int DIpv4LineEdit::cursorPosition() const { D_DC(DIpv4LineEdit); int cursorPosition = 0; for(const QLineEdit *edit : d->editList) { if(edit->hasFocus()) { cursorPosition += edit->cursorPosition(); break; } else { cursorPosition += edit->text().count() + 1; } } return cursorPosition; } Qt::Alignment DIpv4LineEdit::alignment() const { return Qt::AlignHCenter; } bool DIpv4LineEdit::hasAcceptableInput() const { D_DC(DIpv4LineEdit); bool has = true; for(const QLineEdit *edit : d->editList) { has = has && edit->hasAcceptableInput(); } return has; } bool DIpv4LineEdit::isReadOnly() const { return d_func()->editList.first()->isReadOnly(); } void DIpv4LineEdit::setCursorPosition(int cursorPosition) { DLineEdit::setCursorPosition(cursorPosition); D_D(DIpv4LineEdit); for(QLineEdit *edit : d->editList) { if(cursorPosition > edit->text().count()) { cursorPosition -= edit->text().count(); --cursorPosition; } else { edit->setCursorPosition(cursorPosition); edit->setFocus(); break; } } } void DIpv4LineEdit::setReadOnly(bool readOnly) { D_D(DIpv4LineEdit); for(QLineEdit *edit : d->editList) { edit->setReadOnly(readOnly); } } void DIpv4LineEdit::setSelection(int start, int length) { D_D(DIpv4LineEdit); for(QLineEdit *edit : d->editList) { if(edit->text().count() > start) { if(edit->text().count() < length + start) { int tmp_length = edit->text().count() - start; edit->setSelection(start, tmp_length); length -= tmp_length; } else { edit->setSelection(start, length); break; } } else { edit->setSelection(edit->cursorPosition(), 0); } start -= edit->text().count(); } DLineEdit::setSelection(start, length); } void DIpv4LineEdit::selectAll() { D_D(DIpv4LineEdit); for(QLineEdit *edit : d->editList) { edit->selectAll(); } DLineEdit::selectAll(); } bool DIpv4LineEdit::eventFilter(QObject *obj, QEvent *e) { if(e->type() == QEvent::KeyPress) { QLineEdit *edit = qobject_cast(obj); if(edit) { QKeyEvent *event = static_cast(e); if(event) { D_D(DIpv4LineEdit); if(event->key() <= Qt::Key_9 && event->key() >= Qt::Key_0) { if(edit->cursorPosition() == edit->text().count()) { QRegularExpression rx(RX_PATTERN_IP); const QString number = QString::number(event->key() - Qt::Key_0); if(!rx.match(edit->text().append(number)).hasMatch()) { int index = d->editList.indexOf(edit) + 1; if(index < d->editList.count()) { d->editList[index]->setFocus(); if(d->editList[index]->text().isEmpty()) { d->editList[index]->setText(number); d->_q_updateLineEditText(); } } return true; } } } else { if(event->key() == Qt::Key_Backspace) { bool accept = false; for(QLineEdit *edit : d->editList) { if(!edit->selectedText().isEmpty()) { edit->setText(edit->text().remove(edit->selectedText())); d->_q_updateLineEditText(); accept = true; } } if(accept) return true; } if(event->key() == Qt::Key_Left || (event->key() == Qt::Key_Backspace && edit->cursorPosition() == 0)) { setCursorPosition(cursorPosition() - 1); return true; } if(event->key() == Qt::Key_Right) { setCursorPosition(cursorPosition() + 1); return true; } if(event->key() == Qt::Key_Period || event->key() == Qt::Key_Space) { int index = d->editList.indexOf(edit) + 1; if(index < d->editList.count()) { d->editList[index]->setFocus(); } return true; } if(event->modifiers() == Qt::ControlModifier) { if(event->key() == Qt::Key_V) { QString clipboarg_text = qApp->clipboard()->text(); QString text = edit->text().insert(edit->cursorPosition(), clipboarg_text); QRegularExpression rx(RX_PATTERN_IP); if(rx.match(text).hasMatch()) { edit->setText(text); d->_q_updateLineEditText(); } else { int pos = 0; if(this->validator()->validate(clipboarg_text, pos) == QValidator::Acceptable) d->_q_setIpLineEditText(clipboarg_text); } return true; } else if(event->key() == Qt::Key_A) { selectAll(); } else if(event->key() == Qt::Key_X) { cut(); } else { DLineEdit::keyPressEvent(event); } return true; } } } } } else if(e->type() == QEvent::FocusIn) { QLineEdit *edit = qobject_cast(obj); if(edit) { DLineEdit::setCursorPosition(cursorPosition()); } d_func()->setFocus(true); } else if(e->type() == QEvent::FocusOut || e->type() == QEvent::MouseButtonPress) { D_D(DIpv4LineEdit); bool focus = false; for(QLineEdit *edit : d->editList) { edit->setSelection(edit->cursorPosition(), 0); focus = edit->hasFocus() | focus; } if(!focus) d_func()->setFocus(false); } return DLineEdit::eventFilter(obj, e); } #include "moc_dipv4lineedit.cpp" DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dipv4lineedit.h000066400000000000000000000042471325435343100210320ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DIPV4LINEEDIT_H #define DIPV4LINEEDIT_H #include "dlineedit.h" DWIDGET_BEGIN_NAMESPACE class DIpv4LineEditPrivate; class LIBDTKWIDGETSHARED_EXPORT DIpv4LineEdit : public DLineEdit { Q_OBJECT Q_PROPERTY(QString displayText READ displayText) Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition) Q_PROPERTY(Qt::Alignment alignment READ alignment) Q_PROPERTY(QString selectedText READ selectedText) Q_PROPERTY(bool acceptableInput READ hasAcceptableInput) Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) Q_PROPERTY(QString placeholderText READ placeholderText) Q_PROPERTY(bool clearButtonEnabled READ isClearButtonEnabled) public: explicit DIpv4LineEdit(QWidget *parent = 0); QString displayText() const; int cursorPosition() const; Qt::Alignment alignment() const; bool hasAcceptableInput() const; bool isReadOnly() const; public Q_SLOTS: void setCursorPosition(int cursorPosition); void setReadOnly(bool readOnly); void setSelection(int start, int length); void selectAll(); protected: bool eventFilter(QObject *obj, QEvent *e) Q_DECL_OVERRIDE; private: void setPlaceholderText(QString placeholderText); void setClearButtonEnabled(bool clearButtonEnabled); D_DECLARE_PRIVATE(DIpv4LineEdit) Q_PRIVATE_SLOT(d_func(), void _q_updateLineEditText()) Q_PRIVATE_SLOT(d_func(), void _q_setIpLineEditText(const QString &)) }; DWIDGET_END_NAMESPACE #endif // DIPV4LINEEDIT_H dtkwidget-2.0.7.2/src/widgets/dlabel.cpp000066400000000000000000000031071325435343100200360ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dlabel.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DLabel * \brief The DLabel class is a direct subclass of QLabel, styled by deepin to * provide better style unification. */ /*! * \brief DLabel::DLabel constructs an instance of DLabel. * \param parent is passed to QLabel constructor. * \param f is passed to QLabel constructor. */ DLabel::DLabel(QWidget *parent, Qt::WindowFlags f) : QLabel(parent, f) { DThemeManager::registerWidget(this); } /*! * \brief DLabel::DLabel constructs an instance of DLabel. * \param text is used to initialize the content, passed to QLabel constructor. * \param parent is passed to QLabel constructor. * \param f is passed to QLabel constructor. */ DLabel::DLabel(const QString &text, QWidget *parent, Qt::WindowFlags f) : QLabel(text, parent, f) { DThemeManager::registerWidget(this); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dlabel.h000066400000000000000000000020551325435343100175040ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLABEL_H #define DLABEL_H #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DLabel : public QLabel { Q_OBJECT public: DLabel(QWidget * parent = 0, Qt::WindowFlags f = 0); DLabel(const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0); }; DWIDGET_END_NAMESPACE #endif // DLABEL_H dtkwidget-2.0.7.2/src/widgets/dlineedit.cpp000066400000000000000000000150111325435343100205510ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dlineedit.h" #include "dthememanager.h" #include "private/dlineedit_p.h" #include "darrowrectangle.h" #include #include DWIDGET_BEGIN_NAMESPACE /*! * \class DLineEdit * \brief The DLineEdit class provides a styled QLineEdit. * * DLineEdit has an optional action button (DImageButton) at the right side which can be used * to provide extra user interaction, for example: to change the echo mode of * the line edit. * * Also, DLineEdit can be set on or off alert mode, warning the user of some * errors. */ /*! * \brief DLineEdit::DLineEdit constructs an instance of DLineEdit. * \param parent is passed to QLineEdit constructor. */ DLineEdit::DLineEdit(QWidget *parent) : QLineEdit(parent), DObject(*new DLineEditPrivate(this)) { DThemeManager::registerWidget(this, QStringList({"alert"})); Q_D(DLineEdit); d->init(); } DLineEdit::DLineEdit(DLineEditPrivate &q, QWidget *parent) : QLineEdit(parent), DObject(q) { DThemeManager::registerWidget(this, QStringList({"alert"})); Q_D(DLineEdit); d->init(); } void DLineEdit::setAlert(bool isAlert) { Q_D(DLineEdit); if (isAlert == d->m_isAlert) { return; } d->m_isAlert = isAlert; Q_EMIT alertChanged(isAlert); } /*! * \property DLineEdit::alert * \brief This property shows whether the line edit is in alert mode or not. * * There'll be a extra frame colored in orage like color showing if the alert * mode is on, to remind the user that the input is wrong. */ bool DLineEdit::isAlert() const { D_DC(DLineEdit); return d->m_isAlert; } void DLineEdit::showAlertMessage(const QString &text, int duration) { D_D(DLineEdit); if (!d->tooltip) { d->tooltip = new DArrowRectangle(DArrowRectangle::ArrowTop, this); d->tooltip->setObjectName("AlertTooltip"); QLabel *label = new QLabel(d->tooltip); label->setWordWrap(true); label->setMaximumWidth(width()); d->tooltip->setContent(label); d->tooltip->setBackgroundColor(DThemeManager::instance()->theme() == "light" ? Qt::white : Qt::black); d->tooltip->setArrowX(15); d->tooltip->setArrowHeight(5); QTimer::singleShot(duration, d->tooltip, [d] { d->tooltip->deleteLater(); d->tooltip = Q_NULLPTR; }); } QLabel *label = qobject_cast(d->tooltip->getContent()); if (!label) { return; } label->setText(text); label->adjustSize(); const QPoint &pos = mapToGlobal(QPoint(15, height())); d->tooltip->show(pos.x(), pos.y()); } void DLineEdit:: hideAlertMessage() { Q_D(DLineEdit); if (d->tooltip) { d->tooltip->hide(); } } void DLineEdit::setIconVisible(bool visible) { Q_D(DLineEdit); if (visible == d->m_rightIcon->isVisible()) { return; } d->m_rightIcon->setVisible(visible); } /*! * \property DLineEdit::iconVisible * \brief This property holds whether the action button can be seen. */ bool DLineEdit::iconVisible() const { D_DC(DLineEdit); return d->m_rightIcon->isVisible(); } /*! * \property DLineEdit::normalIcon * \brief This property holds the image used as the normal state of the action button. */ QString DLineEdit::normalIcon() const { D_DC(DLineEdit); return d->m_rightIcon->getNormalPic(); } void DLineEdit::setNormalIcon(const QString &normalIcon) { Q_D(DLineEdit); d->m_rightIcon->setNormalPic(normalIcon); } /*! * \property DLineEdit::hoverIcon * \brief This property holds the image used as the hover state of the action button. */ QString DLineEdit::hoverIcon() const { D_DC(DLineEdit); return d->m_rightIcon->getHoverPic(); } void DLineEdit::setHoverIcon(const QString &hoverIcon) { Q_D(DLineEdit); d->m_rightIcon->setHoverPic(hoverIcon); } /*! * \property DLineEdit::pressIcon * \brief This property holds the image used as the pressed state of the action button. */ QString DLineEdit::pressIcon() const { D_DC(DLineEdit); return d->m_rightIcon->getPressPic(); } void DLineEdit::setPressIcon(const QString &pressIcon) { Q_D(DLineEdit); d->m_rightIcon->setPressPic(pressIcon); } void DLineEdit::focusInEvent(QFocusEvent *e) { Q_EMIT focusChanged(true); QLineEdit::focusInEvent(e); Q_D(DLineEdit); d->clearButton->show(); } void DLineEdit::focusOutEvent(QFocusEvent *e) { Q_EMIT focusChanged(false); QLineEdit::focusOutEvent(e); Q_D(DLineEdit); d->clearButton->hide(); } void DLineEdit::resizeEvent(QResizeEvent *e) { QLineEdit::resizeEvent(e); Q_EMIT sizeChanged(e->size()); } DLineEditPrivate::DLineEditPrivate(DLineEdit *q) : DObjectPrivate(q) { } void DLineEditPrivate::init() { Q_Q(DLineEdit); m_insideFrame = new QFrame(q); m_insideFrame->setObjectName("LineEditInsideFrame"); m_rightIcon = new DImageButton(q); m_rightIcon->setObjectName("IconButton"); m_rightIcon->hide(); clearButton = new DImageButton(q); clearButton->setObjectName("ClearButton"); clearButton->hide(); m_centralHLayout = new QHBoxLayout; m_centralHLayout->addStretch(); m_centralHLayout->addWidget(clearButton); m_centralHLayout->addWidget(m_rightIcon); m_centralHLayout->setSpacing(0); m_centralHLayout->setContentsMargins(0, 0, 2, 0); q->setLayout(m_centralHLayout); q->setContextMenuPolicy(Qt::NoContextMenu); q->connect(m_rightIcon, &DImageButton::clicked, q, &DLineEdit::iconClicked); q->connect(q, SIGNAL(sizeChanged(QSize)), q, SLOT(_q_resizeInsideFrame(QSize))); q->connect(clearButton, &DImageButton::clicked, q, [q] { q->setText(QString()); }); } void DLineEditPrivate::_q_resizeInsideFrame(const QSize &size) { m_insideFrame->setFixedHeight(size.height() - 1); m_insideFrame->setFixedWidth(size.width()); } DWIDGET_END_NAMESPACE #include "moc_dlineedit.cpp" dtkwidget-2.0.7.2/src/widgets/dlineedit.h000066400000000000000000000047011325435343100202220ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLINEEDIT_H #define DLINEEDIT_H #include #include "dtkwidget_global.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE class DLineEditPrivate; class LIBDTKWIDGETSHARED_EXPORT DLineEdit : public QLineEdit, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_DISABLE_COPY(DLineEdit) D_DECLARE_PRIVATE(DLineEdit) Q_PROPERTY(bool alert READ isAlert WRITE setAlert NOTIFY alertChanged) Q_PROPERTY(QString normalIcon READ normalIcon WRITE setNormalIcon DESIGNABLE true) Q_PROPERTY(QString hoverIcon READ hoverIcon WRITE setHoverIcon DESIGNABLE true) Q_PROPERTY(QString pressIcon READ pressIcon WRITE setPressIcon DESIGNABLE true) Q_PROPERTY(bool iconVisible READ iconVisible WRITE setIconVisible) public: DLineEdit(QWidget *parent = 0); void setAlert(bool isAlert); bool isAlert() const; void showAlertMessage(const QString &text, int duration = 3000); void hideAlertMessage(); void setIconVisible(bool visible); bool iconVisible() const; QString normalIcon() const; QString hoverIcon() const; QString pressIcon() const; public Q_SLOTS: void setNormalIcon(const QString &normalIcon); void setHoverIcon(const QString &hoverIcon); void setPressIcon(const QString &pressIcon); Q_SIGNALS: void iconClicked() const; void alertChanged(bool alert) const; void focusChanged(bool onFocus) const; void sizeChanged(const QSize &size) const; protected: DLineEdit(DLineEditPrivate &q, QWidget *parent); void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; Q_PRIVATE_SLOT(d_func(), void _q_resizeInsideFrame(const QSize &)) }; DWIDGET_END_NAMESPACE #endif // DLINEEDIT_H dtkwidget-2.0.7.2/src/widgets/dlinkbutton.cpp000066400000000000000000000024131325435343100211470ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dlinkbutton.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DLinkButton * \brief The DLinkButton class provides a styled QPushButton to mini the style * and behavior of links displayed on the internet. */ /*! * \brief DLinkButton::DLinkButton constructs an instance of DLinkButton. * \param text is passed to QPushButton constructor. * \param parent is passed to QPushButton constructor. */ DLinkButton::DLinkButton(const QString &text, QWidget *parent) : QPushButton(text, parent) { DThemeManager::registerWidget(this); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dlinkbutton.h000066400000000000000000000020131325435343100206100ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLINKBUTTON_H #define DLINKBUTTON_H #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DLinkButton : public QPushButton { Q_OBJECT public: DLinkButton(const QString & text = QString(), QWidget * parent = 0); }; DWIDGET_END_NAMESPACE #endif // DLINKBUTTON_H dtkwidget-2.0.7.2/src/widgets/dlistview.cpp000066400000000000000000000324111325435343100206250ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include "dthememanager.h" #include "dboxwidget.h" #include "dlistview.h" #include "private/dlistview_p.h" #include "dflowlayout.h" DWIDGET_BEGIN_NAMESPACE DVariantListModel::DVariantListModel(QObject *parent) : QAbstractListModel(parent) { } int DVariantListModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); return dataList.count(); } QVariant DVariantListModel::data(const QModelIndex &index, int role) const { Q_UNUSED(role); return dataList.value(index.row()); } bool DVariantListModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (index.row() >= 0 && index.row() < dataList.size()) { dataList.replace(index.row(), value); Q_EMIT dataChanged(index, index, QVector() << role); return true; } return false; } bool DVariantListModel::insertRows(int row, int count, const QModelIndex &parent) { if (count < 1 || row < 0 || row > rowCount(parent)) return false; beginInsertRows(QModelIndex(), row, row + count - 1); for (int r = 0; r < count; ++r) dataList.insert(row, QVariant()); endInsertRows(); return true; } bool DVariantListModel::removeRows(int row, int count, const QModelIndex &parent) { if (count <= 0 || row < 0 || (row + count) > rowCount(parent)) return false; beginRemoveRows(QModelIndex(), row, row + count - 1); for (int r = 0; r < count; ++r) dataList.removeAt(row); endRemoveRows(); return true; } DListViewPrivate::DListViewPrivate(DListView *qq) : DObjectPrivate(qq) { } DListViewPrivate::~DListViewPrivate() { } void DListViewPrivate::init() { D_Q(DListView); q->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); q->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); } void DListViewPrivate::onOrientationChanged() { D_Q(DListView); bool isVerticalLayout = (q->orientation() == Qt::Vertical); if(headerLayout) { headerLayout->setDirection(isVerticalLayout ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); if(isVerticalLayout) { headerLayout->resize(q->width(), headerLayout->sizeHint().height()); } else { headerLayout->resize(headerLayout->sizeHint().width(), q->height()); } headerLayout->layout()->update(); } if(footerLayout) { footerLayout->setDirection(isVerticalLayout ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); if(isVerticalLayout) { footerLayout->resize(q->width(), footerLayout->sizeHint().height()); footerLayout->move(0, q->height() - footerLayout->height()); } else { footerLayout->resize(footerLayout->sizeHint().width(), q->height()); footerLayout->move(q->width() - footerLayout->width(), 0); } footerLayout->layout()->update(); } } DListView::DListView(QWidget *parent) : QListView(parent), DObject(*new DListViewPrivate(this)) { DThemeManager::registerWidget(this); d_func()->init(); } QAbstractItemView::State DListView::state() const { return QListView::state(); } void DListView::setFlow(QListView::Flow flow) { QListView::setFlow(flow); } void DListView::setWrapping(bool enable) { QListView::setWrapping(enable); } QWidget *DListView::getHeaderWidget(int index) const { return d_func()->headerList.value(index); } QWidget *DListView::getFooterWidget(int index) const { return d_func()->footerList.value(index); } bool DListView::isActiveRect(const QRect &rect) const { // D_DC(DListView); QRect area = viewport()->geometry(); return area.intersects(rect); } bool DListView::isVisualRect(const QRect &rect) const { const QRect &area = viewport()->geometry(); return area.intersects(rect); } int DListView::count() const { return model()->rowCount(rootIndex()); } Qt::Orientation DListView::orientation() const { bool isVerticalLayout = isWrapping() ? flow() == QListView::LeftToRight : flow() == QListView::TopToBottom; return isVerticalLayout ? Qt::Vertical : Qt::Horizontal; } void DListView::setModel(QAbstractItemModel *model) { QAbstractItemModel *old_model = this->model(); if (old_model) { disconnect(old_model, &QAbstractItemModel::rowsInserted, this, &DListView::rowCountChanged); disconnect(old_model, &QAbstractItemModel::rowsRemoved, this, &DListView::rowCountChanged); } QListView::setModel(model); model = this->model(); if (model) { connect(model, &QAbstractItemModel::rowsInserted, this, &DListView::rowCountChanged); connect(model, &QAbstractItemModel::rowsRemoved, this, &DListView::rowCountChanged); } } bool DListView::addItem(const QVariant &data) { return insertItem(count(), data); } bool DListView::addItems(const QVariantList &datas) { return insertItems(count(), datas); } bool DListView::insertItem(int index, const QVariant &data) { if(!model()->insertRow(index)) return false; return model()->setData(model()->index(index, 0, rootIndex()), data); } bool DListView::insertItems(int index, const QVariantList &datas) { if(!model()->insertRows(index, datas.count())) return false; for(int i = 0; i < datas.count(); ++i) model()->setData(model()->index(index + i, 0, rootIndex()), datas.at(i)); return true; } bool DListView::removeItem(int index) { return model()->removeRow(index); } bool DListView::removeItems(int index, int count) { return model()->removeRows(index, count); } int DListView::addHeaderWidget(QWidget *widget) { D_D(DListView); int index = d->headerList.indexOf(widget); if(index >= 0) return index; if(!d->headerLayout) { bool isVerticalLayout = (orientation() == Qt::Vertical); d->headerLayout = new DBoxWidget(isVerticalLayout ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight, this); if(isVerticalLayout) d->headerLayout->resize(width(), d->headerLayout->height()); else d->headerLayout->resize(d->headerLayout->width(), height()); connect(d->headerLayout, &DBoxWidget::sizeChanged, this, [this](const QSize &size) { bool isVerticalLayout = (orientation() == Qt::Vertical); QMargins margins = this->viewportMargins(); if(isVerticalLayout) margins.setTop(size.height()); else margins.setLeft(size.width()); setViewportMargins(margins); }); d->headerLayout->show(); } d->headerLayout->addWidget(widget); d->headerList << widget; return d->headerList.count() - 1; } void DListView::removeHeaderWidget(int index) { QWidget *widget = takeHeaderWidget(index); if(widget) widget->deleteLater(); } QWidget *DListView::takeHeaderWidget(int index) { D_D(DListView); QWidget *widget = d->headerList.takeAt(index); d->headerLayout->layout()->removeWidget(widget); if(d->headerList.isEmpty()) { d->headerLayout->deleteLater(); d->headerLayout = nullptr; } return widget; } int DListView::addFooterWidget(QWidget *widget) { D_D(DListView); int index = d->footerList.indexOf(widget); if(index >= 0) return index; if(!d->footerLayout) { bool isVerticalLayout = (orientation() == Qt::Vertical); d->footerLayout = new DBoxWidget(isVerticalLayout ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight, this); if(isVerticalLayout) d->footerLayout->resize(width(), d->footerLayout->height()); else d->footerLayout->resize(d->footerLayout->width(), height()); connect(d->footerLayout, &DBoxWidget::sizeChanged, this, [this](const QSize &size) { bool isVerticalLayout = (orientation() == Qt::Vertical); QMargins margins = this->viewportMargins(); D_D(DListView); if(isVerticalLayout) { margins.setBottom(size.height()); d->footerLayout->move(0, height() - d->footerLayout->height()); } else { margins.setRight(size.width()); d->footerLayout->move(width() - d->footerLayout->width(), 0); } setViewportMargins(margins); }); d->footerLayout->show(); } d->footerLayout->addWidget(widget); d->footerList << widget; return d->footerList.count() - 1; } void DListView::removeFooterWidget(int index) { QWidget *widget = takeFooterWidget(index); if(widget) widget->deleteLater(); } QWidget *DListView::takeFooterWidget(int index) { D_D(DListView); QWidget *widget = d->footerList.takeAt(index); d->footerLayout->layout()->removeWidget(widget); if(d->footerList.isEmpty()) { d->footerLayout->deleteLater(); d->footerLayout = nullptr; } return widget; } void DListView::setOrientation(QListView::Flow flow, bool wrapping) { Qt::Orientation old_orientation = this->orientation(); setFlow(flow); setWrapping(wrapping); Qt::Orientation orientation = this->orientation(); if(old_orientation != orientation) { D_D(DListView); QMargins margins = viewportMargins(); if(old_orientation == Qt::Vertical) { if(d->headerLayout) margins.setTop(0); if(d->footerLayout) margins.setBottom(0); } else { if(d->headerLayout) margins.setLeft(0); if(d->footerLayout) margins.setRight(0); } setViewportMargins(margins); d->onOrientationChanged(); Q_EMIT orientationChanged(orientation); } } void DListView::edit(const QModelIndex &index) { QListView::edit(index); } #if(QT_VERSION < 0x050500) void DListView::setViewportMargins(int left, int top, int right, int bottom) { D_D(DListView); d->left = left; d->top = top; d->right = right; d->bottom = bottom; QListView::setViewportMargins(left, top, right, bottom); } void DListView::setViewportMargins(const QMargins &margins) { setViewportMargins(margins.left(), margins.top(), margins.right(), margins.bottom()); } QMargins DListView::viewportMargins() const { D_DC(DListView); return QMargins(d->left, d->top, d->right, d->bottom); } #endif void DListView::resizeEvent(QResizeEvent *event) { QListView::resizeEvent(event); D_D(DListView); bool isVerticalLayout = (orientation() == Qt::Vertical); if(d->headerLayout) { if(isVerticalLayout) d->headerLayout->resize(width(), d->headerLayout->height()); else d->headerLayout->resize(d->headerLayout->width(), height()); } if(d->footerLayout) { if(isVerticalLayout) { d->footerLayout->resize(width(), d->footerLayout->height()); d->footerLayout->move(0, height() - d->footerLayout->height()); } else { d->footerLayout->resize(d->footerLayout->width(), height()); d->footerLayout->move(width() - d->footerLayout->width(), 0); } } } void DListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { QListView::currentChanged(current, previous); Q_EMIT currentChanged(previous); } bool DListView::edit(const QModelIndex &index, QAbstractItemView::EditTrigger trigger, QEvent *event) { if (QWidget *w = indexWidget(index)) { Qt::ItemFlags flags = model()->flags(index); if (((flags & Qt::ItemIsEditable) == 0) || ((flags & Qt::ItemIsEnabled) == 0)) return false; if (state() == QAbstractItemView::EditingState) return false; if (trigger == QAbstractItemView::AllEditTriggers) // force editing return true; if ((trigger & editTriggers()) == QAbstractItemView::SelectedClicked && !selectionModel()->isSelected(index)) return false; if(trigger & editTriggers()) { w->setFocus(); Q_EMIT triggerEdit(index); return true; } } bool tmp = QListView::edit(index, trigger, event); if(tmp) Q_EMIT triggerEdit(index); return tmp; } #include "moc_dlistview.cpp" DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dlistview.h000066400000000000000000000073271325435343100203020ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLISTVIEW_H #define DLISTVIEW_H #include "dtkwidget_global.h" #include #include #include DWIDGET_BEGIN_NAMESPACE class DVariantListModel : public QAbstractListModel { public: explicit DVariantListModel(QObject *parent = 0); int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; bool setData(const QModelIndex &index, const QVariant &value, int role) Q_DECL_OVERRIDE; bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE; private: QList dataList; }; class DListViewPrivate; class LIBDTKWIDGETSHARED_EXPORT DListView : public QListView, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT /// item count. Q_PROPERTY(int count READ count NOTIFY rowCountChanged) /// list layout orientation Q_PROPERTY(Qt::Orientation orientation READ orientation NOTIFY orientationChanged) public: explicit DListView(QWidget *parent = 0); State state() const; QWidget *getHeaderWidget(int index) const; QWidget *getFooterWidget(int index) const; /// return true if rect intersects contentsVisualRect+qMax(cacheBuffer,cacheCount) bool isActiveRect(const QRect &rect) const; bool isVisualRect(const QRect &rect) const; int count() const; Qt::Orientation orientation() const; void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE; public Q_SLOTS: bool addItem(const QVariant &data); bool addItems(const QVariantList &datas); bool insertItem(int index, const QVariant &data); bool insertItems(int index, const QVariantList &datas); bool removeItem(int index); bool removeItems(int index, int count); int addHeaderWidget(QWidget *widget); void removeHeaderWidget(int index); QWidget *takeHeaderWidget(int index); int addFooterWidget(QWidget *widget); void removeFooterWidget(int index); QWidget *takeFooterWidget(int index); void setOrientation(QListView::Flow flow, bool wrapping); void edit(const QModelIndex &index); Q_SIGNALS: void rowCountChanged(); void orientationChanged(Qt::Orientation orientation); void currentChanged(const QModelIndex &previous); void triggerEdit(const QModelIndex &index); protected: #if(QT_VERSION < 0x050500) void setViewportMargins(int left, int top, int right, int bottom); void setViewportMargins(const QMargins &margins); QMargins viewportMargins() const; #endif void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) Q_DECL_OVERRIDE; bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event) Q_DECL_OVERRIDE; private: void setFlow(QListView::Flow flow); void setWrapping(bool enable); D_DECLARE_PRIVATE(DListView) }; DWIDGET_END_NAMESPACE #endif // DLISTVIEW_H dtkwidget-2.0.7.2/src/widgets/dlistwidget.cpp000066400000000000000000000271641325435343100211470ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include "dthememanager.h" #include "dlistwidget.h" #include "private/dlistwidget_p.h" DWIDGET_BEGIN_NAMESPACE DListWidgetPrivate::DListWidgetPrivate(DListWidget *qq): DScrollAreaPrivate(qq), itemWidth(-1), itemHeight(-1), checkMode(DListWidget::Radio), mainWidget(new DBoxWidget(QBoxLayout::TopToBottom)), visibleCount(0), checkable(false), toggleable(false), enableHorizontalScroll(false), enableVerticalScroll(false) { } DListWidgetPrivate::~DListWidgetPrivate() { } void DListWidgetPrivate::init() { Q_Q(DListWidget); mainWidget->setObjectName("MainWidget"); q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); q->setAlignment(Qt::AlignHCenter); q->setFrameStyle(QFrame::NoFrame); q->setFrameShape(QFrame::NoFrame); q->setWidget(mainWidget); QObject::connect(mainWidget, &DBoxWidget::sizeChanged, q, &DListWidget::updateSize); } DListWidget::DListWidget(CheckMode checkMode, QWidget *parent) : DScrollArea(*new DListWidgetPrivate(this), parent) { DThemeManager::registerWidget(this); d_func()->checkMode = checkMode; d_func()->init(); } DListWidget::DListWidget(QBoxLayout::Direction direction, DListWidget::CheckMode checkMode, QWidget *parent) : DScrollArea(*new DListWidgetPrivate(this), parent) { DThemeManager::registerWidget(this); d_func()->mainWidget->setDirection(direction); d_func()->checkMode = checkMode; d_func()->init(); } int DListWidget::addWidget(QWidget *w, Qt::Alignment a) { insertWidget(-1, w, a); return count()-1; } void DListWidget::addWidgets(const QList &ws, Qt::Alignment a) { insertWidgets(-1, ws, a); } void DListWidget::insertWidget(int index, QWidget *w, Qt::Alignment a) { Q_D(DListWidget); if(w==NULL || d->widgetList.contains(w)) return; if(d->itemWidth>0){ w->setFixedWidth(d->itemWidth); } if(d->itemHeight>0){ w->setFixedHeight(d->itemHeight); } if(index < 0) { d->widgetList << w; d->mainWidget->layout()->addWidget(w, 0, a); } else { d->widgetList.insert(index, w); d->mainWidget->layout()->insertWidget(index, w, 0, a); } d->mapVisible[w] = true; setVisibleCount(d->visibleCount + 1); Q_EMIT countChanged(count()); } void DListWidget::insertWidgets(int index, const QList &ws, Qt::Alignment a) { if(index < 0) { Q_FOREACH (QWidget *w, ws) { insertWidget(-1, w, a); } } else { Q_FOREACH (QWidget *w, ws) { insertWidget(index++, w, a); } } } void DListWidget::setItemSize(int w, int h) { Q_D(DListWidget); d->itemWidth = w; d->itemHeight = h; if(d->itemWidth <= 0 && d->itemHeight <= 0) return; Q_FOREACH (QWidget *w, d->widgetList) { if(d->itemWidth>0) w->setFixedWidth(d->itemWidth); if(d->itemHeight>0){ w->setFixedHeight(d->itemHeight); } } } void DListWidget::clear(bool isDelete) { Q_D(DListWidget); for(int i=0;imainWidget->layout()->takeAt(i); d->widgetList[i]->setParent(NULL); if(isDelete) d->widgetList[i]->deleteLater(); } d->mapVisible.clear(); d->widgetList.clear(); d->checkedList.clear(); resize(0, 0); setVisibleCount(0); Q_EMIT countChanged(count()); } void DListWidget::removeWidget(int index, bool isDelete) { Q_D(DListWidget); QWidget *w = getWidget(index); d->widgetList.removeAt(index); delete d->mainWidget->layout()->takeAt(index); d->checkedList.removeOne(index); if(d->mapVisible.value(w, false)){ setVisibleCount(d->visibleCount -1); } d->mapVisible.remove(w); w->setParent(NULL); if(isDelete) w->deleteLater(); Q_EMIT countChanged(count()); } void DListWidget::showWidget(int index) { Q_D(DListWidget); QWidget *w = getWidget(index); if(!d->mapVisible.value(w, true)){ w->show(); d->mapVisible[w] = true; setVisibleCount(d->visibleCount+1); } } void DListWidget::hideWidget(int index) { Q_D(DListWidget); QWidget *w = getWidget(index); if(d->mapVisible.value(w, false)){ w->hide(); d->mapVisible[w] = false; setVisibleCount(d->visibleCount-1); } } void DListWidget::setChecked(int index, bool checked) { Q_D(DListWidget); if (!d->checkable || (checked && isChecked(index)) || (!checked && !isChecked(index))) return; if(d->checkMode == Radio && checked){ int checkedWidget = firstChecked(); if(checkedWidget>=0){ getWidget(checkedWidget)->setProperty("checked", false); d->checkedList.removeOne(checkedWidget); } } if(index>=0 && index < count()){ QWidget *w = getWidget(index); w->setProperty("checked", checked); } if(checked){ d->checkedList << index; }else{ d->checkedList.removeOne(index); } if(d->checkMode == Radio && checked){ Q_EMIT firstCheckedChanged(index); } Q_EMIT checkedChanged(index, checked); } void DListWidget::setCheckMode(DListWidget::CheckMode checkMode) { Q_D(DListWidget); d->checkMode = checkMode; } void DListWidget::setCheckable(bool checkable) { Q_D(DListWidget); if (d->checkable == checkable) return; d->checkable = checkable; } void DListWidget::setToggleable(bool enableUncheck) { Q_D(DListWidget); if (d->toggleable == enableUncheck) return; d->toggleable = enableUncheck; Q_EMIT toggleableChanged(enableUncheck); } void DListWidget::setEnableHorizontalScroll(bool enableHorizontalScroll) { Q_D(DListWidget); if (d->enableHorizontalScroll == enableHorizontalScroll) return; d->enableHorizontalScroll = enableHorizontalScroll; updateSize(); Q_EMIT enableHorizontalScrollChanged(enableHorizontalScroll); } void DListWidget::setEnableVerticalScroll(bool enableVerticalScroll) { Q_D(DListWidget); if (d->enableVerticalScroll == enableVerticalScroll) return; d->enableVerticalScroll = enableVerticalScroll; updateSize(); Q_EMIT enableVerticalScrollChanged(enableVerticalScroll); } void DListWidget::setSpacing(int spacing) { Q_D(DListWidget); d->mainWidget->layout()->setSpacing(spacing); } void DListWidget::setDirection(QBoxLayout::Direction direction) { Q_D(DListWidget); d->mainWidget->layout()->setDirection(direction); } int DListWidget::count() const { Q_D(const DListWidget); return d->widgetList.count(); } int DListWidget::indexOf(const QWidget* w) { Q_D(DListWidget); return d->widgetList.indexOf(const_cast(w)); } QWidget *DListWidget::getWidget(int index) const { Q_D(const DListWidget); return d->widgetList[index]; } int DListWidget::firstChecked() const { Q_D(const DListWidget); return d->checkedList.count()>0 ? d->checkedList.first() : -1; } QList DListWidget::checkedList() const { Q_D(const DListWidget); return d->checkedList; } bool DListWidget::checkable() const { Q_D(const DListWidget); return d->checkable; } bool DListWidget::toggleable() const { Q_D(const DListWidget); return d->toggleable; } bool DListWidget::isChecked(int index) const { Q_D(const DListWidget); return d->checkedList.contains(index); } int DListWidget::visibleCount() const { Q_D(const DListWidget); return d->visibleCount; } int DListWidget::spacing() const { Q_D(const DListWidget); return d->mainWidget->layout()->spacing(); } QBoxLayout::Direction DListWidget::direction() const { Q_D(const DListWidget); return d->mainWidget->direction(); } DListWidget::CheckMode DListWidget::checkMode() const { Q_D(const DListWidget); return d->checkMode; } void DListWidget::mouseReleaseEvent(QMouseEvent *e) { if(!checkable()){ return DScrollArea::mouseReleaseEvent(e); } Q_D(DListWidget); QWidget *widget = childAt(e->pos()); while(widget && widget->parentWidget() != d->mainWidget) { widget = widget->parentWidget(); } int index = indexOf(widget); if(index>=0){ if(toggleable()) setChecked(index, !isChecked(index)); else setChecked(index, true); Q_EMIT clicked(index); } } void DListWidget::setVisibleCount(int count) { Q_D(DListWidget); if(d->visibleCount == count) return; d->visibleCount = count; Q_EMIT visibleCountChanged(count); } void DListWidget::updateSize() { Q_D(DListWidget); if(!d->enableHorizontalScroll) { if(direction() == QBoxLayout::LeftToRight || direction() == QBoxLayout::RightToLeft) setFixedWidth(d->mainWidget->width()); else setMinimumWidth(d->mainWidget->width()); } else { setMinimumWidth(qMin(d->mainWidget->width(), maximumWidth())); } if(!d->enableVerticalScroll) { if(direction() == QBoxLayout::TopToBottom || direction() == QBoxLayout::BottomToTop) setFixedHeight(d->mainWidget->height()); else setMinimumHeight(d->mainWidget->height()); } else { setMinimumHeight(qMin(d->mainWidget->height(), maximumHeight())); } } QList DListWidget::widgetList() const { Q_D(const DListWidget); return d->widgetList; } QSize DListWidget::itemSize() const { Q_D(const DListWidget); return QSize(d->itemWidth, d->itemHeight); } bool DListWidget::enableHorizontalScroll() const { Q_D(const DListWidget); return d->enableHorizontalScroll; } bool DListWidget::enableVerticalScroll() const { Q_D(const DListWidget); return d->enableVerticalScroll; } void DListWidget::setContentsMargins(int left, int top, int right, int bottom) { Q_D(DListWidget); d->mainWidget->layout()->setContentsMargins(left, top, right, bottom); } void DListWidget::setContentsMargins(const QMargins &margins) { Q_D(DListWidget); d->mainWidget->layout()->setContentsMargins(margins); } void DListWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) const { Q_D(const DListWidget); d->mainWidget->layout()->getContentsMargins(left, top, right, bottom); } QMargins DListWidget::contentsMargins() const { Q_D(const DListWidget); return d->mainWidget->layout()->contentsMargins(); } QRect DListWidget::contentsRect() const { Q_D(const DListWidget); return d->mainWidget->layout()->contentsRect(); } QSize DListWidget::sizeHint() const { return minimumSize(); } DListWidget::DListWidget(DListWidgetPrivate &dd, QWidget *parent): DScrollArea(dd, parent) { DThemeManager::registerWidget(this); d_func()->init(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dlistwidget.h000066400000000000000000000110511325435343100206000ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLISTWIDGET_H #define DLISTWIDGET_H #include #include #include "dscrollarea.h" #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DListWidgetPrivate; class DListWidget : public DScrollArea { Q_OBJECT Q_PROPERTY(int firstChecked READ firstChecked NOTIFY firstCheckedChanged) Q_PROPERTY(int count READ count NOTIFY countChanged FINAL) Q_PROPERTY(int visibleCount READ visibleCount NOTIFY visibleCountChanged FINAL) Q_PROPERTY(int spacing READ spacing WRITE setSpacing) Q_PROPERTY(QBoxLayout::Direction direction READ direction WRITE setDirection) Q_PROPERTY(bool checkable READ checkable WRITE setCheckable) Q_PROPERTY(bool toggleable READ toggleable WRITE setToggleable NOTIFY toggleableChanged) Q_PROPERTY(bool enableHorizontalScroll READ enableHorizontalScroll WRITE setEnableHorizontalScroll NOTIFY enableHorizontalScrollChanged) Q_PROPERTY(bool enableVerticalScroll READ enableVerticalScroll WRITE setEnableVerticalScroll NOTIFY enableVerticalScrollChanged) Q_PROPERTY(CheckMode checkMode READ checkMode) Q_ENUMS(CheckMode) public: enum CheckMode{ Radio, MultipleCheck }; explicit DListWidget(CheckMode checkMode = Radio, QWidget *parent = 0); explicit DListWidget(QBoxLayout::Direction direction, CheckMode checkMode = Radio, QWidget *parent = 0); public Q_SLOTS: int addWidget(QWidget *w, Qt::Alignment a = Qt::AlignHCenter); void addWidgets(const QList &ws, Qt::Alignment a = Qt::AlignHCenter); void insertWidget(int index, QWidget *w, Qt::Alignment a = Qt::AlignHCenter); void insertWidgets(int index, const QList &ws, Qt::Alignment a = Qt::AlignHCenter); void setItemSize(int w, int h); void clear(bool isDelete = true); void removeWidget(int index, bool isDelete = true); void showWidget(int index); void hideWidget(int index); void setChecked(int index, bool checked); void setCheckMode(CheckMode checkMode); void setCheckable(bool checkable); void setToggleable(bool toggleable); void setEnableHorizontalScroll(bool enableHorizontalScroll); void setEnableVerticalScroll(bool enableVerticalScroll); void setSpacing(int spacing); void setDirection(QBoxLayout::Direction direction); public: int count() const; int indexOf(const QWidget* widget); QWidget *getWidget(int index) const; int firstChecked() const; QList checkedList() const; bool checkable() const; bool toggleable() const; bool isChecked(int index) const; int visibleCount() const; int spacing() const; QBoxLayout::Direction direction() const; CheckMode checkMode() const; QList widgetList() const; QSize itemSize() const; bool enableHorizontalScroll() const; bool enableVerticalScroll() const; void setContentsMargins(int left, int top, int right, int bottom); void setContentsMargins(const QMargins &margins); void getContentsMargins(int *left, int *top, int *right, int *bottom) const; QMargins contentsMargins() const; QRect contentsRect() const; QSize sizeHint() const Q_DECL_OVERRIDE; Q_SIGNALS: void firstCheckedChanged(int index); void checkedChanged(int index, bool checked); void countChanged(int count); void checkableChanged(bool checkable); void toggleableChanged(bool toggleable); void visibleCountChanged(int visibleCount); void clicked(int index); void enableHorizontalScrollChanged(bool enableHorizontalScroll); void enableVerticalScrollChanged(bool enableVerticalScroll); private Q_SLOTS: void updateSize(); protected: DListWidget(DListWidgetPrivate &dd, QWidget *parent); void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE; void setVisibleCount(int count); private: Q_DISABLE_COPY(DListWidget) D_DECLARE_PRIVATE(DListWidget) }; DWIDGET_END_NAMESPACE #endif // DLISTWIDGET_H dtkwidget-2.0.7.2/src/widgets/dloadingindicator.cpp000066400000000000000000000227001325435343100222710ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include "dloadingindicator.h" #include "private/dloadingindicator_p.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE DLoadingIndicatorPrivate::DLoadingIndicatorPrivate(DLoadingIndicator *qq) : DObjectPrivate(qq) { } void DLoadingIndicatorPrivate::init() { D_Q(DLoadingIndicator); q->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); q->setScene(new QGraphicsScene(q)); q->setRenderHint(QPainter::SmoothPixmapTransform); q->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); rotateAni.setDuration(1000); rotateAni.setEasingCurve(QEasingCurve::OutInQuad); rotateAni.setLoopCount(-1); rotateAni.setStartValue(QVariant(qreal(0.0))); rotateAni.setEndValue(QVariant(qreal(360.0))); q->connect(&rotateAni, SIGNAL(valueChanged(QVariant)), q, SLOT(setRotate(QVariant))); } void DLoadingIndicatorPrivate::setLoadingItem(QGraphicsItem *item) { D_QC(DLoadingIndicator); QSizeF itemSize = item->boundingRect().size(); item->setPos((q->width()-itemSize.width())/2, (q->height()-itemSize.height())/2); item->setTransformOriginPoint(itemSize.width()/2, itemSize.height()/2); q->scene()->clear(); q->scene()->addItem(item); } /*! * \class DLoadingIndicator * \brief The DLoadingIndicator class provides a widget that showing loading animation. * * DLoadingIndicator renders and rotates the source set by * DLoadingIndicator::setWidgetSource or DLoadingIndicator::setImageSource, * the rotation animation is runing in a given duration and at a given easing curve, * those two properties can be accessed by DLoadingIndicator::aniDuration and * DLoadingIndicator::aniEasingType . */ /*! * \brief DLoadingIndicator::DLoadingIndicator constructs an instance of DLoadingIndicator. * \param parent is passed to QGraphicsView constructor. */ DLoadingIndicator::DLoadingIndicator(QWidget *parent) : QGraphicsView(parent), DObject(*new DLoadingIndicatorPrivate(this)) { DThemeManager::registerWidget(this); d_func()->init(); } DLoadingIndicator::~DLoadingIndicator() { D_DC(DLoadingIndicator); if(d->widgetSource) d->widgetSource->deleteLater(); } /*! * \property DLoadingIndicator::backgroundColor * \brief This property holds the background color of this widget. */ QColor DLoadingIndicator::backgroundColor() const { return scene()->backgroundBrush().color(); } void DLoadingIndicator::setRotate(QVariant angle) { if(!scene()->items().isEmpty()) scene()->items().first()->setRotation(angle.toReal()); } void DLoadingIndicator::setWidgetSource(QWidget *widgetSource) { D_D(DLoadingIndicator); if(d->widgetSource) d->widgetSource->deleteLater(); d->widgetSource = widgetSource; QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget; proxy->setWidget(widgetSource); d->setLoadingItem(proxy); } void DLoadingIndicator::setImageSource(const QPixmap &imageSource) { D_D(DLoadingIndicator); QGraphicsPixmapItem * item = new QGraphicsPixmapItem(imageSource); if(d->smooth) item->setTransformationMode(Qt::SmoothTransformation); d->setLoadingItem(item); } void DLoadingIndicator::setAniEasingType(QEasingCurve::Type aniEasingType) { setAniEasingCurve(aniEasingType); } void DLoadingIndicator::setSmooth(bool smooth) { D_D(DLoadingIndicator); if(d->smooth == smooth) return; d->smooth = smooth; QGraphicsPixmapItem * item = nullptr; if(!scene()->items().isEmpty()) item = dynamic_cast(scene()->items().first()); if(smooth){ setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing); if(item) item->setTransformationMode(Qt::SmoothTransformation); }else{ setRenderHint(QPainter::SmoothPixmapTransform, false); setRenderHint(QPainter::Antialiasing, false); if(item) item->setTransformationMode(Qt::FastTransformation); } } void DLoadingIndicator::setDirection(DLoadingIndicator::RotationDirection direction) { D_D(DLoadingIndicator); if (d->direction == direction) return; d->direction = direction; if(direction == Clockwise) { d->rotateAni.setStartValue(QVariant(qreal(0.0))); d->rotateAni.setEndValue(QVariant(qreal(360.0))); } else { d->rotateAni.setStartValue(QVariant(qreal(0.0))); d->rotateAni.setEndValue(QVariant(qreal(-360.0))); } Q_EMIT directionChanged(direction); } void DLoadingIndicator::resizeEvent(QResizeEvent *e) { QGraphicsView::resizeEvent(e); setSceneRect(QRectF(rect())); for(QGraphicsItem *item : items()) { QSizeF itemSize = item->boundingRect().size(); item->setPos((width()-itemSize.width())/2, (height()-itemSize.height())/2); } } void DLoadingIndicator::setLoading(bool flag) { if (flag == true){ start(); } else { stop(); } } void DLoadingIndicator::setAniDuration(int msecs) { D_D(DLoadingIndicator); d->rotateAni.setDuration(msecs); } /*! * \brief DLoadingIndicator::setAniEasingCurve sets an easing curve on the loading animation. * \param easing * * This property defines the easing curve of the animation. * By default, a linear easing curve is used, resulting in linear interpolation. * Other curves are provided, for instance, QEasingCurve::InCirc, * which provides a circular entry curve. * Another example is QEasingCurve::InOutElastic, * which provides an elastic effect on the values of the interpolated variant. */ void DLoadingIndicator::setAniEasingCurve(const QEasingCurve & easing) { D_D(DLoadingIndicator); d->rotateAni.setEasingCurve(easing); } void DLoadingIndicator::setBackgroundColor(const QColor &color) { scene()->setBackgroundBrush(color); } /*! * \property DLoadingIndicator::loading * \brief This property holds the animation state. * * It returns true if the animation is running, false otherwise, you can also * set value on this property to run or stop the animation. */ bool DLoadingIndicator::loading() const { D_DC(DLoadingIndicator); return d->rotateAni.state() == QVariantAnimation::Running; } /*! * \property DLoadingIndicator::widgetSource * \brief This property holds the widget to be rendered as the content of the * loading indicator. */ QWidget *DLoadingIndicator::widgetSource() const { D_DC(DLoadingIndicator); return d->widgetSource; } /*! * \property DLoadingIndicator::imageSource * \brief This property holds the image to be rendered as the content of the * loading indicator. */ QPixmap DLoadingIndicator::imageSource() const { QGraphicsPixmapItem * item = nullptr; if(!scene()->items().isEmpty()) item = dynamic_cast(scene()->items().first()); return item ? item->pixmap() : QPixmap(); } /*! * \property DLoadingIndicator::aniDuration * \brief This property holds the duration of the loading animation. */ int DLoadingIndicator::aniDuration() const { D_DC(DLoadingIndicator); return d->rotateAni.duration(); } /*! * \property DLoadingIndicator::aniEasingType * \brief This property holds the easing type of the easing curve used by the * loading animation. */ QEasingCurve::Type DLoadingIndicator::aniEasingType() const { D_DC(DLoadingIndicator); return d->rotateAni.easingCurve().type(); } QSize DLoadingIndicator::sizeHint() const { return scene()->sceneRect().size().toSize(); } /*! * \property DLoadingIndicator::smooth * \brief This property holds whether the rendered content are antialiased or * smoothly filtered. * * Smooth filtering gives better visual quality, but it may be slower on * some hardware. */ bool DLoadingIndicator::smooth() const { D_DC(DLoadingIndicator); return d->smooth; } /*! * \property DLoadingIndicator::direction * \brief This property holds the direction used while doing the rotation animation. */ DLoadingIndicator::RotationDirection DLoadingIndicator::direction() const { D_DC(DLoadingIndicator); return d->direction; } /*! * \property DLoadingIndicator::rotate * \brief This property holds the current rotation of the content. * * This property is usually used to correct the rotation of the content after * calling DLoadingIndicator::stop to stop the animation. */ qreal DLoadingIndicator::rotate() const { if(!scene()->items().isEmpty()) return scene()->items().first()->rotation(); return 0; } /*! * \brief DLoadingIndicator::start starts the loading animation. */ void DLoadingIndicator::start() { D_D(DLoadingIndicator); d->rotateAni.start(); } /*! * \brief DLoadingIndicator::stop stops the loading animation. */ void DLoadingIndicator::stop() { D_D(DLoadingIndicator); d->rotateAni.stop(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dloadingindicator.h000066400000000000000000000066611325435343100217460ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLOADINGINDICATOR_H #define DLOADINGINDICATOR_H #include #include #include #include #include #include #include #include #include #include #include #include "dtkwidget_global.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE class DLoadingIndicatorPrivate; class LIBDTKWIDGETSHARED_EXPORT DLoadingIndicator : public QGraphicsView, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor DESIGNABLE true SCRIPTABLE true) Q_PROPERTY(bool loading READ loading WRITE setLoading) Q_PROPERTY(bool smooth READ smooth WRITE setSmooth) Q_PROPERTY(QPixmap imageSource READ imageSource WRITE setImageSource) Q_PROPERTY(QWidget* widgetSource READ widgetSource WRITE setWidgetSource) Q_PROPERTY(int aniDuration READ aniDuration WRITE setAniDuration) Q_PROPERTY(QEasingCurve::Type aniEasingType READ aniEasingType WRITE setAniEasingType) Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) Q_PROPERTY(qreal rotate READ rotate WRITE setRotate NOTIFY rotateChanged) public: /*! * \brief The RotationDirection enum contains the possible rotation * directions of the DLoadingIndicator widget. */ enum RotationDirection{ Clockwise, /*!< the rotation is clockwise */ Counterclockwise /*!< the rotation is counterclockwise */ }; Q_ENUMS(RotationDirection) DLoadingIndicator(QWidget * parent = 0); ~DLoadingIndicator(); QColor backgroundColor() const; bool loading() const; QWidget* widgetSource() const; QPixmap imageSource() const; int aniDuration() const; QEasingCurve::Type aniEasingType() const; QSize sizeHint() const Q_DECL_OVERRIDE; bool smooth() const; RotationDirection direction() const; qreal rotate() const; public Q_SLOTS: void start(); void stop(); void setLoading(bool flag); void setAniDuration(int msecs); void setAniEasingCurve(const QEasingCurve & easing); void setBackgroundColor(const QColor &color); void setRotate(QVariant angle); void setWidgetSource(QWidget* widgetSource); void setImageSource(const QPixmap &imageSource); void setAniEasingType(QEasingCurve::Type aniEasingType); void setSmooth(bool smooth); void setDirection(RotationDirection direction); Q_SIGNALS: void directionChanged(RotationDirection direction); void rotateChanged(qreal rotate); protected: void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DLoadingIndicator) }; DWIDGET_END_NAMESPACE #endif // DLOADINGINDICATOR_H dtkwidget-2.0.7.2/src/widgets/dmainwindow.cpp000066400000000000000000000306431325435343100211400ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dmainwindow.h" #include "dplatformwindowhandle.h" #include "dapplication.h" #include "dtitlebar.h" #include "private/dmainwindow_p.h" #include "private/dapplication_p.h" #include #include #include #include #ifdef Q_OS_MAC #include "osxwindow.h" #endif /// shadow #define SHADOW_COLOR_NORMAL QColor(0, 0, 0, 255 * 35/100) #define SHADOW_COLOR_ACTIVE QColor(0, 0, 0, 255 * 60/100) DWIDGET_BEGIN_NAMESPACE DMainWindowPrivate::DMainWindowPrivate(DMainWindow *qq) : DObjectPrivate(qq) { titlebar = new DTitlebar(qq); if (DApplication::isDXcbPlatform()) { handle = new DPlatformWindowHandle(qq, qq); qq->setMenuWidget(titlebar); } else { qq->setMenuWidget(titlebar); #ifdef Q_OS_MAC OSX::HideWindowTitlebar(qq->winId()); #else titlebar->setEmbedMode(true); #endif } } void DMainWindowPrivate::init() { D_Q(DMainWindow); const DApplication *dapp = qobject_cast(qApp); if (dapp) { q->setWindowTitle(dapp->productName()); } else { q->setWindowTitle(qApp->applicationDisplayName()); } if (handle) { q->connect(handle, &DPlatformWindowHandle::borderColorChanged, q, &DMainWindow::borderColorChanged); q->connect(handle, &DPlatformWindowHandle::borderWidthChanged, q, &DMainWindow::borderWidthChanged); q->connect(handle, &DPlatformWindowHandle::clipPathChanged, q, &DMainWindow::clipPathChanged); q->connect(handle, &DPlatformWindowHandle::frameMarginsChanged, q, &DMainWindow::frameMarginsChanged); q->connect(handle, &DPlatformWindowHandle::frameMaskChanged, q, &DMainWindow::frameMaskChanged); q->connect(handle, &DPlatformWindowHandle::shadowColorChanged, q, &DMainWindow::shadowColorChanged); q->connect(handle, &DPlatformWindowHandle::shadowOffsetChanged, q, &DMainWindow::shadowOffsetChanged); q->connect(handle, &DPlatformWindowHandle::shadowRadiusChanged, q, &DMainWindow::shadowRadiusChanged); q->connect(handle, &DPlatformWindowHandle::windowRadiusChanged, q, &DMainWindow::windowRadiusChanged); q->connect(handle, &DPlatformWindowHandle::translucentBackgroundChanged, q, &DMainWindow::translucentBackgroundChanged); q->connect(handle, &DPlatformWindowHandle::enableSystemMoveChanged, q, &DMainWindow::enableSystemMoveChanged); q->connect(handle, &DPlatformWindowHandle::enableSystemResizeChanged, q, &DMainWindow::enableSystemResizeChanged); q->connect(handle, &DPlatformWindowHandle::enableBlurWindowChanged, q, &DMainWindow::enableBlurWindowChanged); q->connect(handle, &DPlatformWindowHandle::autoInputMaskByClipPathChanged, q, &DMainWindow::autoInputMaskByClipPathChanged); q->connect(qApp, &QGuiApplication::focusWindowChanged, q, [q] { if (q->isActiveWindow()) { q->setShadowColor(SHADOW_COLOR_ACTIVE); } else { q->setShadowColor(SHADOW_COLOR_NORMAL); } }); } if (!help && DApplicationPrivate::isUserManualExists()) { help = new QShortcut(QKeySequence(Qt::Key_F1), q); help->setContext(Qt::ApplicationShortcut); QObject::connect(help, &QShortcut::activated, q, [ = ]() { DApplication *dapp = qobject_cast(qApp); if (dapp) { dapp->handleHelpAction(); } }); } } /*! * \class DMainWindow * \brief The DMainWindow class provides a main application window. * * A main window provides a framework for building an application's user * interface. DMainWindow has its own layout compared to QMainWindow, * it has only title bar and content area, simpler and cleaner. * * Developers can provide customized title bar and content to make the * application rich functional. */ /*! * \brief DMainWindow::DMainWindow constructs an instance of DMainWindow * \param parent is passed to QMainWindow construtor. */ DMainWindow::DMainWindow(QWidget *parent) : QMainWindow(parent) , DObject(*new DMainWindowPrivate(this)) { d_func()->init(); } /*! * \brief DMainWindow::titlebar * \return a DTitlebar instance used by the main window. */ DTitlebar *DMainWindow::titlebar() const { D_DC(DMainWindow); return d->titlebar; } /*! * \brief DMainWindow::isDXcbWindow * \return Whether this window is dxcb backended. * * Many features like blurred background and window clipping are supported * only if the window is using the dxcb Qt platform plugin. */ bool DMainWindow::isDXcbWindow() const { D_DC(DMainWindow); return d->handle; } /*! * \property DMainWindow::windowRadius * \brief This property holds the radius of the main window. */ int DMainWindow::windowRadius() const { D_DC(DMainWindow); if (!d->handle) { return 0; } return d->handle->windowRadius(); } /*! * \property DMainWindow::borderWidth * \brief This property holds the width of the main window's border. */ int DMainWindow::borderWidth() const { D_DC(DMainWindow); if (!d->handle) { return 0; } return d->handle->borderWidth(); } /*! * \property DMainWindow::borderColor * \brief This property holds the color of the main window's border. */ QColor DMainWindow::borderColor() const { D_DC(DMainWindow); if (!d->handle) { return QColor(); } return d->handle->borderColor(); } /*! * \property DMainWindow::shadowRadius * \brief This property holds the shadow radius of the main widnow. */ int DMainWindow::shadowRadius() const { D_DC(DMainWindow); if (!d->handle) { return 0; } return d->handle->shadowRadius(); } /*! * \property DMainWindow::shadowOffset * \brief This property holds the offset applied on the window shadow. */ QPoint DMainWindow::shadowOffset() const { D_DC(DMainWindow); if (!d->handle) { return QPoint(); } return d->handle->shadowOffset(); } /*! * \property DMainWindow::shadowColor * \brief This property holds the color of the window shadow. */ QColor DMainWindow::shadowColor() const { D_DC(DMainWindow); if (!d->handle) { return QColor(); } return d->handle->shadowColor(); } /*! * \property DMainWindow::clipPath * \brief This property holds the custom QPainterPath to be used to clip the window. * * By default DMainWindow is clipped as a corner-rounded rectangle, but you can * supply a custom QPainterPath to do custom shaped window. * * \see DMainWindow::frameMask */ QPainterPath DMainWindow::clipPath() const { D_DC(DMainWindow); if (!d->handle) { return QPainterPath(); } return d->handle->clipPath(); } /*! * \property DMainWindow::frameMask * \brief This property holds the mask to be applied on the window. * * For better clip quality, for example antialiasing, use property * DMainWindow::clipPath instead. */ QRegion DMainWindow::frameMask() const { D_DC(DMainWindow); if (!d->handle) { return QRegion(); } return d->handle->frameMask(); } QMargins DMainWindow::frameMargins() const { D_DC(DMainWindow); if (!d->handle) { return QMargins(); } return d->handle->frameMargins(); } /*! * \property DMainWindow::translucentBackground * \brief This property holds whether the window has translucent background. */ bool DMainWindow::translucentBackground() const { D_DC(DMainWindow); if (!d->handle) { return false; } return d->handle->translucentBackground(); } /*! * \brief DMainWindow::enableSystemResize * \return This property holds whether the window can be resized by the user. * * The default value of this property is true. * * You can set this property to false and implement the resize polizy of this * window by you self. */ bool DMainWindow::enableSystemResize() const { D_DC(DMainWindow); if (!d->handle) { return false; } return d->handle->enableSystemResize(); } /*! * \property DMainWindow::enableSystemMove * \brief This property holds whether the window can be moved by the user. * * The default value of this property is true. * * You can set this property to false and choose the effective area to drag and move. */ bool DMainWindow::enableSystemMove() const { D_DC(DMainWindow); if (!d->handle) { return false; } return d->handle->enableSystemResize(); } /*! * \property DMainWindow::enableBlurWindow * \brief This property holds whether the window background is blurred. */ bool DMainWindow::enableBlurWindow() const { D_DC(DMainWindow); if (!d->handle) { return false; } return d->handle->enableBlurWindow(); } /*! * \property DMainWindow::autoInputMaskByClipPath * \brief This property holds whether the user input is masked by the clip path. * * Sometimes you may want to handle events happening in the areas that are * visually clipped by the setting DMainWindow::clipPath. * * The default value of this property is true. */ bool DMainWindow::autoInputMaskByClipPath() const { D_DC(DMainWindow); if (!d->handle) { return false; } return d->handle->autoInputMaskByClipPath(); } void DMainWindow::setWindowRadius(int windowRadius) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setWindowRadius(windowRadius); } void DMainWindow::setBorderWidth(int borderWidth) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setBorderWidth(borderWidth); } void DMainWindow::setBorderColor(const QColor &borderColor) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setBorderColor(borderColor); } void DMainWindow::setShadowRadius(int shadowRadius) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setShadowRadius(shadowRadius); } void DMainWindow::setShadowOffset(const QPoint &shadowOffset) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setShadowOffset(shadowOffset); } void DMainWindow::setShadowColor(const QColor &shadowColor) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setShadowColor(shadowColor); } void DMainWindow::setClipPath(const QPainterPath &clipPath) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setClipPath(clipPath); } void DMainWindow::setFrameMask(const QRegion &frameMask) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setFrameMask(frameMask); } void DMainWindow::setTranslucentBackground(bool translucentBackground) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setTranslucentBackground(translucentBackground); } void DMainWindow::setEnableSystemResize(bool enableSystemResize) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setEnableSystemResize(enableSystemResize); } void DMainWindow::setEnableSystemMove(bool enableSystemMove) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setEnableSystemMove(enableSystemMove); } void DMainWindow::setEnableBlurWindow(bool enableBlurWindow) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setEnableBlurWindow(enableBlurWindow); } void DMainWindow::setAutoInputMaskByClipPath(bool autoInputMaskByClipPath) { D_D(DMainWindow); if (!d->handle) { return; } d->handle->setAutoInputMaskByClipPath(autoInputMaskByClipPath); } #ifdef Q_OS_MAC void DMainWindow::setWindowFlags(Qt::WindowFlags type) { QMainWindow::setWindowFlags(type); OSX::HideWindowTitlebar(winId()); } #endif DMainWindow::DMainWindow(DMainWindowPrivate &dd, QWidget *parent) : QMainWindow(parent) , DObject(dd) { d_func()->init(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dmainwindow.h000066400000000000000000000107631325435343100206060ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DMAINWINDOW_H #define DMAINWINDOW_H #include "dtkwidget_global.h" #include "dobject.h" #include DWIDGET_BEGIN_NAMESPACE class DMainWindowPrivate; class DTitlebar; class LIBDTKWIDGETSHARED_EXPORT DMainWindow : public QMainWindow, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(int windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged) Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) Q_PROPERTY(int shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY shadowRadiusChanged) Q_PROPERTY(QPoint shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged) Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged) Q_PROPERTY(QPainterPath clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged) Q_PROPERTY(QRegion frameMask READ frameMask WRITE setFrameMask NOTIFY frameMaskChanged) Q_PROPERTY(QMargins frameMargins READ frameMargins NOTIFY frameMarginsChanged) Q_PROPERTY(bool translucentBackground READ translucentBackground WRITE setTranslucentBackground NOTIFY translucentBackgroundChanged) Q_PROPERTY(bool enableSystemResize READ enableSystemResize WRITE setEnableSystemResize NOTIFY enableSystemResizeChanged) Q_PROPERTY(bool enableSystemMove READ enableSystemMove WRITE setEnableSystemMove NOTIFY enableSystemMoveChanged) Q_PROPERTY(bool enableBlurWindow READ enableBlurWindow WRITE setEnableBlurWindow NOTIFY enableBlurWindowChanged) Q_PROPERTY(bool autoInputMaskByClipPath READ autoInputMaskByClipPath WRITE setAutoInputMaskByClipPath NOTIFY autoInputMaskByClipPathChanged) public: explicit DMainWindow(QWidget *parent = 0); DTitlebar *titlebar() const; bool isDXcbWindow() const; int windowRadius() const; int borderWidth() const; QColor borderColor() const; int shadowRadius() const; QPoint shadowOffset() const; QColor shadowColor() const; QPainterPath clipPath() const; QRegion frameMask() const; QMargins frameMargins() const; bool translucentBackground() const; bool enableSystemResize() const; bool enableSystemMove() const; bool enableBlurWindow() const; bool autoInputMaskByClipPath() const; public Q_SLOTS: void setWindowRadius(int windowRadius); void setBorderWidth(int borderWidth); void setBorderColor(const QColor &borderColor); void setShadowRadius(int shadowRadius); void setShadowOffset(const QPoint &shadowOffset); void setShadowColor(const QColor &shadowColor); void setClipPath(const QPainterPath &clipPath); void setFrameMask(const QRegion &frameMask); void setTranslucentBackground(bool translucentBackground); void setEnableSystemResize(bool enableSystemResize); void setEnableSystemMove(bool enableSystemMove); void setEnableBlurWindow(bool enableBlurWindow); void setAutoInputMaskByClipPath(bool autoInputMaskByClipPath); // TODO: remove it if there is an batter sulotion #ifdef Q_OS_MAC void setWindowFlags(Qt::WindowFlags type); #endif Q_SIGNALS: void windowRadiusChanged(); void borderWidthChanged(); void borderColorChanged(); void shadowRadiusChanged(); void shadowOffsetChanged(); void shadowColorChanged(); void clipPathChanged(); void frameMaskChanged(); void frameMarginsChanged(); void translucentBackgroundChanged(); void enableSystemResizeChanged(); void enableSystemMoveChanged(); void enableBlurWindowChanged(); void autoInputMaskByClipPathChanged(); protected: DMainWindow(DMainWindowPrivate &dd, QWidget *parent = 0); private: D_DECLARE_PRIVATE(DMainWindow) }; DWIDGET_END_NAMESPACE #endif // DMAINWINDOW_H dtkwidget-2.0.7.2/src/widgets/dmpriscontrol.cpp000066400000000000000000000137041325435343100215160ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dmpriscontrol.h" #include "private/dmpriscontrol_p.h" #include "private/mpris/dmprismonitor.h" #include #include #include DWIDGET_USE_NAMESPACE DMPRISControl::DMPRISControl(QWidget *parent) : QFrame(parent), DObject(*new DMPRISControlPrivate(this)) { D_D(DMPRISControl); d->init(); } bool DMPRISControl::isWorking() const { D_DC(DMPRISControl); return d->m_mprisInter; } DMPRISControlPrivate::DMPRISControlPrivate(DMPRISControl *q) : DObjectPrivate(q), m_mprisInter(nullptr) { } void DMPRISControlPrivate::init() { D_Q(DMPRISControl); m_mprisMonitor = new DMPRISMonitor(q); m_title = new QLabel; m_title->setAlignment(Qt::AlignCenter); m_picture = new QLabel; m_picture->setFixedSize(200, 200); m_prevBtn = new DImageButton; m_prevBtn->setObjectName("PrevBtn"); m_pauseBtn = new DImageButton; m_pauseBtn->setObjectName("PauseBtn"); m_playBtn = new DImageButton; m_playBtn->setObjectName("PlayBtn"); m_nextBtn = new DImageButton; m_nextBtn->setObjectName("NextBtn"); #ifdef QT_DEBUG m_title->setText("MPRIS Title"); m_nextBtn->setNormalPic("://images/arrow_right_normal.png"); m_pauseBtn->setNormalPic("://images/arrow_left_white.png"); m_playBtn->setNormalPic("://images/arrow_right_white.png"); m_prevBtn->setNormalPic("://images/arrow_left_normal.png"); #endif QHBoxLayout *controlLayout = new QHBoxLayout; controlLayout->addWidget(m_prevBtn); controlLayout->addStretch(); controlLayout->addWidget(m_pauseBtn); controlLayout->addWidget(m_playBtn); controlLayout->addStretch(); controlLayout->addWidget(m_nextBtn); controlLayout->setContentsMargins(0, 10, 0, 0); QVBoxLayout *centralLayout = new QVBoxLayout; centralLayout->addWidget(m_title); centralLayout->addWidget(m_picture); centralLayout->setAlignment(m_picture, Qt::AlignCenter); centralLayout->addLayout(controlLayout); centralLayout->setMargin(0); q->setLayout(centralLayout); q->connect(m_mprisMonitor, SIGNAL(mprisAcquired(const QString &)), q, SLOT(_q_loadMPRISPath(const QString &))); q->connect(m_mprisMonitor, SIGNAL(mprisLost(const QString &)), q, SLOT(_q_removeMPRISPath(const QString &))); q->connect(m_prevBtn, SIGNAL(clicked()), q, SLOT(_q_onPrevClicked())); q->connect(m_pauseBtn, SIGNAL(clicked()), q, SLOT(_q_onPauseClicked())); q->connect(m_playBtn, SIGNAL(clicked()), q, SLOT(_q_onPlayClicked())); q->connect(m_nextBtn, SIGNAL(clicked()), q, SLOT(_q_onNextClicked())); m_mprisMonitor->init(); } void DMPRISControlPrivate::_q_onPrevClicked() { if (!m_mprisInter) return; m_mprisInter->Previous(); } void DMPRISControlPrivate::_q_onPlayClicked() { if (!m_mprisInter) return; m_mprisInter->Play(); } void DMPRISControlPrivate::_q_onPauseClicked() { if (!m_mprisInter) return; m_mprisInter->Pause(); } void DMPRISControlPrivate::_q_onNextClicked() { if (!m_mprisInter) return; m_mprisInter->Next(); } void DMPRISControlPrivate::_q_onMetaDataChanged() { if (!m_mprisInter) return; const auto meta = m_mprisInter->metadata(); const QString title = meta.value("xesam:title").toString(); const QString artist = meta.value("xesam:artist").toString(); const QUrl pictureUrl = meta.value("mpris:artUrl").toString(); const QPixmap picture = QPixmap(pictureUrl.toLocalFile()); if (title.isEmpty()) m_title->clear(); else { if (artist.isEmpty()) m_title->setText(title); else m_title->setText(QString("%1 - %2").arg(title).arg(artist)); } m_picture->setPixmap(picture); m_picture->setVisible(false); // m_picture->setVisible(!picture.isNull()); } void DMPRISControlPrivate::_q_onPlaybackStatusChanged() { const QString stat = m_mprisInter->playbackStatus(); if (stat == "Playing") { m_pauseBtn->setVisible(true); m_playBtn->setVisible(false); } else { m_pauseBtn->setVisible(false); m_playBtn->setVisible(true); } } void DMPRISControlPrivate::_q_loadMPRISPath(const QString &path) { D_Q(DMPRISControl); const bool hasOld = m_mprisInter; m_lastPath = path; // save paths if (!m_mprisPaths.contains(path)) m_mprisPaths.append(path); if (m_mprisInter) m_mprisInter->deleteLater(); m_mprisInter = new DBusMPRIS(path, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), q); q->connect(m_mprisInter, SIGNAL(MetadataChanged(QVariantMap)), q, SLOT(_q_onMetaDataChanged())); q->connect(m_mprisInter, SIGNAL(PlaybackStatusChanged(QString)), q, SLOT(_q_onPlaybackStatusChanged())); _q_onMetaDataChanged(); _q_onPlaybackStatusChanged(); if (hasOld) Q_EMIT q->mprisChanged(); else Q_EMIT q->mprisAcquired(); } void DMPRISControlPrivate::_q_removeMPRISPath(const QString &path) { D_QC(DMPRISControl); m_mprisPaths.removeOne(path); if (m_lastPath != path) return; if (!m_mprisInter) return; if (!m_mprisPaths.isEmpty()) return _q_loadMPRISPath(m_mprisPaths.last()); m_mprisInter->deleteLater(); m_mprisInter = nullptr; Q_EMIT q->mprisLosted(); } #include "moc_dmpriscontrol.cpp" dtkwidget-2.0.7.2/src/widgets/dmpriscontrol.h000066400000000000000000000032561325435343100211640ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DMPRISCONTROL_H #define DMPRISCONTROL_H #include "dobject.h" #include "dtkwidget_global.h" #include DWIDGET_BEGIN_NAMESPACE class DMPRISControlPrivate; class LIBDTKWIDGETSHARED_EXPORT DMPRISControl : public QFrame, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_DISABLE_COPY(DMPRISControl) D_DECLARE_PRIVATE(DMPRISControl) public: explicit DMPRISControl(QWidget *parent = 0); bool isWorking() const; Q_SIGNALS: void mprisAcquired() const; void mprisChanged() const; void mprisLosted() const; protected: D_PRIVATE_SLOT(void _q_onMetaDataChanged()) D_PRIVATE_SLOT(void _q_onPlaybackStatusChanged()) D_PRIVATE_SLOT(void _q_onPrevClicked()) D_PRIVATE_SLOT(void _q_onPlayClicked()) D_PRIVATE_SLOT(void _q_onPauseClicked()) D_PRIVATE_SLOT(void _q_onNextClicked()) D_PRIVATE_SLOT(void _q_loadMPRISPath(const QString &)) D_PRIVATE_SLOT(void _q_removeMPRISPath(const QString &)) }; DWIDGET_END_NAMESPACE #endif // DMPRISCONTROL_H dtkwidget-2.0.7.2/src/widgets/doption.cpp000066400000000000000000000100521325435343100202640ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "doption.h" #include "dtkwidget_global.h" #include "dthememanager.h" #include "private/doption_p.h" #include #include DWIDGET_BEGIN_NAMESPACE DOptionPrivate::DOptionPrivate(DOption *q) : DObjectPrivate(q) { } void DOptionPrivate::init() { D_Q(DOption); m_checkedIconLabel = new QLabel; m_checkedIconLabel->setMinimumSize(0, 0); m_checkedIconLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_optionIcon = new QLabel; m_optionIcon->setMinimumSize(0, 0); m_optionIcon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_optionName = new QLabel; m_optionName->setObjectName("OptionName"); m_optionName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_layout = new QHBoxLayout; m_layout->addWidget(m_checkedIconLabel); m_layout->addWidget(m_optionIcon); m_layout->addWidget(m_optionName); m_layout->setSpacing(5); m_layout->setContentsMargins(0, 0, 0, 0); q->setLayout(m_layout); } void DOptionPrivate::setIcon(const QString &iconName) { setIcon(QPixmap(iconName)); } void DOptionPrivate::setIcon(const QPixmap &icon) { m_optionIcon->setPixmap(icon); } const QString DOptionPrivate::name() const { return m_optionName->text(); } const QString DOptionPrivate::value() const { return m_optionValue; } bool DOptionPrivate::checked() const { return m_checked; } void DOptionPrivate::setChecked(bool checked) { if (m_checked == checked) return; m_checked = checked; D_QC(DOption); Q_EMIT q->checkedChanged(m_checked); } const QString DOptionPrivate::checkedIcon() const { return m_checkedIconName; } void DOptionPrivate::setCheckedIcon(const QString &icon) { if (icon == m_checkedIconName) return; m_checkedIconName = icon; m_checkedIconLabel->setPixmap(QPixmap(icon)); D_QC(DOption); Q_EMIT q->checkedIconChanged(icon); } void DOptionPrivate::sizeChanged(QResizeEvent *e) { D_Q(DOption); Q_EMIT q->sizeChanged(e->size()); } DOption::DOption(QWidget *parent) : QFrame(parent), DObject(*new DOptionPrivate(this)) { DThemeManager::registerWidget(this, QStringList({"checked"})); D_D(DOption); d->init(); } void DOption::setName(const QString &name) { D_D(DOption); d->m_optionName->setText(name); } void DOption::setValue(const QString &value) { D_D(DOption); d->m_optionValue = value; } void DOption::setIcon(const QString &icon) { D_D(DOption); d->setIcon(icon); } void DOption::setIcon(const QPixmap &icon) { D_D(DOption); d->setIcon(icon); } const QString DOption::value() const { D_DC(DOption); return d->value(); } const QString DOption::name() const { D_DC(DOption); return d->name(); } bool DOption::checked() const { D_DC(DOption); return d->checked(); } void DOption::setChecked(bool checked) { D_D(DOption); d->setChecked(checked); } const QString DOption::checkedIcon() const { D_DC(DOption); return d->checkedIcon(); } void DOption::setCheckedIcon(const QString &icon) { D_D(DOption); d->setCheckedIcon(icon); } QHBoxLayout *DOption::layout() { D_D(DOption); return d->m_layout; } void DOption::resizeEvent(QResizeEvent *e) { QWidget::resizeEvent(e); D_D(DOption); d->sizeChanged(e); } DWIDGET_END_NAMESPACE #include "moc_doption.cpp" dtkwidget-2.0.7.2/src/widgets/doption.h000066400000000000000000000036561325435343100177450ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DOPTION_H #define DOPTION_H #include "dtkwidget_global.h" #include "dobject.h" #include #include DWIDGET_BEGIN_NAMESPACE class DOptionPrivate; class LIBDTKWIDGETSHARED_EXPORT DOption : public QFrame, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_DISABLE_COPY(DOption) D_DECLARE_PRIVATE(DOption) Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY checkedChanged) Q_PROPERTY(QString checkedIcon READ checkedIcon WRITE setCheckedIcon NOTIFY checkedIconChanged DESIGNABLE true) public: DOption(QWidget *parent = nullptr); void setName(const QString &name); void setValue(const QString &value); void setIcon(const QString &icon); void setIcon(const QPixmap &icon); const QString value() const; const QString name() const; bool checked() const; void setChecked(bool checked); const QString checkedIcon() const; void setCheckedIcon(const QString &icon); QHBoxLayout *layout(); protected: void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; Q_SIGNALS: void sizeChanged(const QSize &size) const; void checkedChanged(bool checked) const; void checkedIconChanged(const QString checkedIcon) const; }; DWIDGET_END_NAMESPACE #endif // DOPTION_H dtkwidget-2.0.7.2/src/widgets/doptionlist.cpp000066400000000000000000000070771325435343100211750ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "doptionlist.h" #include "dtkwidget_global.h" #include "dthememanager.h" #include "private/doptionlist_p.h" #include DWIDGET_BEGIN_NAMESPACE DOptionListPrivate::DOptionListPrivate(DOptionList *q) : DObjectPrivate(q) { } void DOptionListPrivate::init() { D_Q(DOptionList); q->setSelectionMode(QAbstractItemView::SingleSelection); q->connect(q, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), q, SLOT(_q_currentItemChanged(QListWidgetItem*,QListWidgetItem*))); } void DOptionListPrivate::addOption(DOption *option) { QListWidgetItem *item = new QListWidgetItem; m_optionList.insert(item, option); D_Q(DOptionList); q->connect(option, &DOption::sizeChanged, [item] (const QSize &size) {item->setSizeHint(size);}); q->addItem(item); q->setItemWidget(item, option); } void DOptionListPrivate::insertOption(int pos, DOption *option) { QListWidgetItem *item = new QListWidgetItem; m_optionList.insert(item, option); D_Q(DOptionList); q->connect(option, &DOption::sizeChanged, [item] (const QSize &size) {item->setSizeHint(size);}); q->insertItem(pos, item); q->setItemWidget(item, option); } void DOptionListPrivate::setCurrentSelected(int pos) { D_Q(DOptionList); DOption *prevItem = m_optionList.value(q->currentItem(), nullptr); if (prevItem) prevItem->setChecked(false); QListWidgetItem *item = q->item(pos); q->setCurrentItem(item); DOption *currentItem = m_optionList.value(item, nullptr); if (currentItem) currentItem->setChecked(true); } void DOptionListPrivate::setCurrentSelected(const QString &value) { D_Q(DOptionList); const QList list = m_optionList.values(); for (DOption *option : list) if (option->value() == value) return setCurrentSelected(q->row(m_optionList.key(option))); } void DOptionListPrivate::_q_currentItemChanged(QListWidgetItem *current,QListWidgetItem *previous) { DOption *currentItem = m_optionList.value(current, nullptr); DOption *previousItem = m_optionList.value(previous, nullptr); if (currentItem) currentItem->setChecked(true); if (previousItem) previousItem->setChecked(false); } DOptionList::DOptionList(QWidget *parent) : QListWidget(parent), DObject(*new DOptionListPrivate(this)) { DThemeManager::registerWidget(this); D_D(DOptionList); d->init(); } void DOptionList::addOption(DOption *option) { D_D(DOptionList); d->addOption(option); } void DOptionList::insertOption(int pos, DOption *option) { D_D(DOptionList); d->insertOption(pos, option); } void DOptionList::setCurrentSelected(int pos) { D_D(DOptionList); d->setCurrentSelected(pos); } void DOptionList::setCurrentSelected(const QString &value) { D_D(DOptionList); d->setCurrentSelected(value); } DWIDGET_END_NAMESPACE #include "moc_doptionlist.cpp" dtkwidget-2.0.7.2/src/widgets/doptionlist.h000066400000000000000000000026611325435343100206340ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DOPTIONLIST_H #define DOPTIONLIST_H #include "dtkwidget_global.h" #include "dobject.h" #include "doption.h" #include DWIDGET_BEGIN_NAMESPACE class DOptionListPrivate; class LIBDTKWIDGETSHARED_EXPORT DOptionList : public QListWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_DISABLE_COPY(DOptionList) D_DECLARE_PRIVATE(DOptionList) public: explicit DOptionList(QWidget *parent = nullptr); void addOption(DOption *option); void insertOption(int pos, DOption *option); void setCurrentSelected(int pos); void setCurrentSelected(const QString &value); protected: D_PRIVATE_SLOT(void _q_currentItemChanged(QListWidgetItem*,QListWidgetItem*)) }; DWIDGET_END_NAMESPACE #endif // DOPTIONLIST_H dtkwidget-2.0.7.2/src/widgets/dpageindicator.cpp000066400000000000000000000142671325435343100216010ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dpageindicator.h" #include "private/dpageindicator_p.h" #include #include DWIDGET_BEGIN_NAMESPACE /*! * \class DPageIndicator * \brief The DPageIndicator class provides indicator of which page is currently showing. * * DPageIndicator is control that displays a horizontal series of dots, * each of which corresponds to a page/widget may appear on top of it. * * It's inspired by UIPageControl of Apple. * See https://developer.apple.com/documentation/uikit/uipagecontrol. * * \note The design of this control is that it's just used to display, not * to control which page is currently visible. */ /*! * \brief DPageIndicator::DPageIndicator constructs an instance of DPageIndicator. * \param parent is passed to QWidget constructor. */ DPageIndicator::DPageIndicator(QWidget *parent) : QWidget(parent), DObject(*new DPageIndicatorPrivate(this), this) { } /*! * \property DPageIndicator::pageCount * \brief This property holds the number of pages that are represented by this widget. */ int DPageIndicator::pageCount() const { D_DC(DPageIndicator); return d->pageCount; } void DPageIndicator::setPageCount(const int count) { D_D(DPageIndicator); d->setPageCount(count); } /*! * \brief DPageIndicator::nextPage highlights the next dot. * * \see DPageIndicator::setCurrentPage. */ void DPageIndicator::nextPage() { D_D(DPageIndicator); d->nextPage(); } /*! * \brief DPageIndicator::previousPage hightlights the previous dot. * * \see DPageIndicator::setCurrentPage. */ void DPageIndicator::previousPage() { D_D(DPageIndicator); d->previousPage(); } void DPageIndicator::setCurrentPage(const int index) { D_D(DPageIndicator); d->setCurrentPage(index); } /*! * \property DPageIndicator::currentPage * \brief This property holds the index of currently highlighted dot. */ int DPageIndicator::currentPageIndex() const { D_DC(DPageIndicator); return d->currentPage; } /*! * \property DPageIndicator::pointColor * \brief This property holds the color used to draw the highlighted dot. */ QColor DPageIndicator::pointColor() const { D_DC(DPageIndicator); return d->pointColor; } void DPageIndicator::setPointColor(QColor color) { D_D(DPageIndicator); d->pointColor = color; } /*! * \property DPageIndicator::secondaryPointColor * \brief This property holds the color used to draw the noraml dots. */ QColor DPageIndicator::secondaryPointColor() const { D_DC(DPageIndicator); return d->secondaryPointColor; } void DPageIndicator::setSecondaryPointColor(QColor color) { D_D(DPageIndicator); d->secondaryPointColor = color; } /*! * \property DPageIndicator::pointRadius * \brief This property holds the radius of the highlighted dot. */ int DPageIndicator::pointRadius() const { D_DC(DPageIndicator); return d->pointRadius; } void DPageIndicator::setPointRadius(int size) { D_D(DPageIndicator); d->pointRadius = size; } /*! * \property DPageIndicator::secondaryPointRadius * \brief This property holds the radius of the normal dot. */ int DPageIndicator::secondaryPointRadius() const { D_DC(DPageIndicator); return d->secondaryPointRadius; } void DPageIndicator::setSecondaryPointRadius(int size) { D_D(DPageIndicator); d->secondaryPointRadius = size; } /*! * \property DPageIndicator::pointDistance * \brief This property holds the distance between two dots. */ int DPageIndicator::pointDistance() const { D_DC(DPageIndicator); return d->pointDistance; } void DPageIndicator::setPointDistance(int distance) { D_D(DPageIndicator); d->pointDistance = distance; } void DPageIndicator::paintEvent(QPaintEvent *e) { QWidget::paintEvent(e); const int w = width(); const int h = height(); D_DC(DPageIndicator); const int total_w = d->pageCount * d->pointDistance; const QPoint offset = QPoint((w - total_w) / 2, h / 2); QColor currentPtColor = d->pointColor; QColor nonCurrentPtColor = d->secondaryPointColor; QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::transparent); for (int i(0); i != d->pageCount; ++i) { if (d->currentPage == i) { painter.setBrush(currentPtColor); painter.drawEllipse(offset + QPoint(d->pointDistance / 2 + d->pointDistance * i, 0), d->pointRadius, d->pointRadius); } else { painter.setBrush(nonCurrentPtColor); painter.drawEllipse(offset + QPoint(d->pointDistance / 2 + d->pointDistance * i, 0), d->secondaryPointRadius, d->secondaryPointRadius); } } } DPageIndicatorPrivate::DPageIndicatorPrivate(DPageIndicator *q) : DObjectPrivate(q), pageCount(0), currentPage(-1), pointColor(Qt::red) { } void DPageIndicatorPrivate::setPageCount(const int count) { pageCount = count; D_Q(DPageIndicator); q->update(); } void DPageIndicatorPrivate::nextPage() { currentPage = (currentPage + 1) % pageCount; D_Q(DPageIndicator); q->update(); } void DPageIndicatorPrivate::previousPage() { currentPage = (currentPage ? currentPage : pageCount) - 1; D_Q(DPageIndicator); q->update(); } void DPageIndicatorPrivate::setCurrentPage(const int index) { if (index < -1 || index >= pageCount) { qWarning() << "index out of bounds: " << index << ", max is " << pageCount; return; } currentPage = index; D_Q(DPageIndicator); q->update(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dpageindicator.h000066400000000000000000000045201325435343100212350ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DPAGEINDICATOR_H #define DPAGEINDICATOR_H #include "dtkwidget_global.h" #include "dobject.h" #include DWIDGET_BEGIN_NAMESPACE class DPageIndicatorPrivate; class LIBDTKWIDGETSHARED_EXPORT DPageIndicator : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_DISABLE_COPY(DPageIndicator) D_DECLARE_PRIVATE(DPageIndicator) Q_PROPERTY(QColor pointColor READ pointColor WRITE setPointColor DESIGNABLE true) Q_PROPERTY(QColor secondaryPointColor READ secondaryPointColor WRITE setSecondaryPointColor DESIGNABLE true) Q_PROPERTY(int pointRadius READ pointRadius WRITE setPointRadius) Q_PROPERTY(int secondaryPointRadius READ secondaryPointRadius WRITE setSecondaryPointRadius) Q_PROPERTY(int pageCount READ pageCount WRITE setPageCount) Q_PROPERTY(int currentPage READ currentPageIndex WRITE setCurrentPage) Q_PROPERTY(int pointDistance READ pointDistance WRITE setPointDistance) public: explicit DPageIndicator(QWidget *parent = 0); int pageCount() const; void setPageCount(const int count); void nextPage(); void previousPage(); void setCurrentPage(const int index); int currentPageIndex() const; QColor pointColor() const; void setPointColor(QColor color); QColor secondaryPointColor() const; void setSecondaryPointColor(QColor color); int pointRadius() const; void setPointRadius(int size); int secondaryPointRadius() const; void setSecondaryPointRadius(int size); int pointDistance() const; void setPointDistance(int distance); protected: void paintEvent(QPaintEvent *e) override; }; DWIDGET_END_NAMESPACE #endif // DPAGEINDICATOR_H dtkwidget-2.0.7.2/src/widgets/dpasswordedit.cpp000066400000000000000000000054561325435343100215000ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dpasswordedit.h" #include "dthememanager.h" #include "private/dpasswordedit_p.h" #include #include #include DWIDGET_BEGIN_NAMESPACE /*! * \class DPasswordEdit * \brief The DPasswordEdit class provides a widget to let user input password. */ /*! * \brief DPasswordEdit::DPasswordEdit constructs an instance of DPasswordEdit. * \param parent is passed to DLineEdit constructor. */ DPasswordEdit::DPasswordEdit(QWidget *parent) : DLineEdit(*new DPasswordEditPrivate(this), parent) { // This will do the trick refreshing your style sheet for you // after your registered property changed. DThemeManager::registerWidget(this, QStringList({"isEchoMode"})); D_D(DPasswordEdit); d->init(); } /*! * \property DPasswordEdit::isEchoMode * \brief This property holds whether the user input should be displayed directly * or show as dots. * * \see QLineEdit::EchoMode */ bool DPasswordEdit::isEchoMode() const { return echoMode() == Normal; } void DPasswordEdit::setEchoMode(QLineEdit::EchoMode mode) { if (mode != echoMode()) { QLineEdit::setEchoMode(mode); // To inform the style sheet system that our style sheet needs // to be recalculated. Q_EMIT echoModeChanged(mode == Normal); } } DPasswordEditPrivate::DPasswordEditPrivate(DPasswordEdit *q) : DLineEditPrivate(q) { } void DPasswordEditPrivate::init() { D_Q(DPasswordEdit); q->layout()->setContentsMargins(0, 0, 1, 0); q->setEchoMode(q->Password); q->setTextMargins(0, 0, 16 + 22 + 5, 0); q->setIconVisible(true); // FIXME: DPasswordEdit instances that initialized with a parent will fail // to load the little eye icon if we don't do the below thing. DUtil::TimerSingleShot(0, [q] { q->setStyleSheet(q->styleSheet()); }); q->connect(q, SIGNAL(iconClicked()), q, SLOT(_q_toggleEchoMode())); } void DPasswordEditPrivate::_q_toggleEchoMode() { D_Q(DPasswordEdit); if (q->isEchoMode()) { q->setEchoMode(q->Password); } else { q->setEchoMode(q->Normal); } } DWIDGET_END_NAMESPACE #include "moc_dpasswordedit.cpp" dtkwidget-2.0.7.2/src/widgets/dpasswordedit.h000066400000000000000000000024721325435343100211400ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DPASSWORDEDIT_H #define DPASSWORDEDIT_H #include "dlineedit.h" DWIDGET_BEGIN_NAMESPACE class DPasswordEditPrivate; class LIBDTKWIDGETSHARED_EXPORT DPasswordEdit : public DLineEdit { Q_OBJECT Q_PROPERTY(bool isEchoMode READ isEchoMode NOTIFY echoModeChanged) public: DPasswordEdit(QWidget *parent = nullptr); bool isEchoMode() const; void setEchoMode(EchoMode mode); Q_SIGNALS: void echoModeChanged(bool echoOn); protected: Q_DISABLE_COPY(DPasswordEdit) D_DECLARE_PRIVATE(DPasswordEdit) Q_PRIVATE_SLOT(d_func(), void _q_toggleEchoMode()) }; DWIDGET_END_NAMESPACE #endif // DPASSWORDEDIT_H dtkwidget-2.0.7.2/src/widgets/dpicturesequenceview.cpp000066400000000000000000000126721325435343100230650ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dpicturesequenceview.h" #include "private/dpicturesequenceview_p.h" #include #include #include DWIDGET_BEGIN_NAMESPACE DPictureSequenceViewPrivate::DPictureSequenceViewPrivate(DPictureSequenceView *q) : DObjectPrivate(q) { } DPictureSequenceViewPrivate::~DPictureSequenceViewPrivate() { for (auto *item : pictureItemList) { scene->removeItem(item); delete item; } scene->deleteLater(); } void DPictureSequenceViewPrivate::init() { D_Q(DPictureSequenceView); scene = new QGraphicsScene(q); refreshTimer = new QTimer(q); refreshTimer->setInterval(33); q->setScene(scene); q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); q->setFrameShape(QFrame::NoFrame); q->connect(refreshTimer, SIGNAL(timeout()), q, SLOT(_q_refreshPicture())); } void DPictureSequenceViewPrivate::play() { D_Q(DPictureSequenceView); refreshTimer->start(); } QPixmap DPictureSequenceViewPrivate::loadPixmap(const QString &path) { D_Q(DPictureSequenceView); qreal ratio = 1.0; const qreal devicePixelRatio = q->devicePixelRatioF(); QPixmap pixmap; if (!qFuzzyCompare(ratio, devicePixelRatio)) { QImageReader reader; reader.setFileName(qt_findAtNxFile(path, devicePixelRatio, &ratio)); if (reader.canRead()) { reader.setScaledSize(reader.size() * (devicePixelRatio / ratio)); pixmap = QPixmap::fromImage(reader.read()); pixmap.setDevicePixelRatio(devicePixelRatio); } } else { pixmap.load(path); } return pixmap; } void DPictureSequenceViewPrivate::_q_refreshPicture() { QGraphicsPixmapItem *item = pictureItemList.value(lastItemPos++); if (item) item->hide(); if (lastItemPos == pictureItemList.count()) { lastItemPos = 0; if (singleShot) refreshTimer->stop(); D_QC(DPictureSequenceView); Q_EMIT q->playEnd(); } item = pictureItemList.value(lastItemPos); if (item) item->show(); } DPictureSequenceView::DPictureSequenceView(QWidget *parent) : QGraphicsView(parent), DObject(*new DPictureSequenceViewPrivate(this)) { D_D(DPictureSequenceView); d->init(); } void DPictureSequenceView::setPictureSequence(const QString &src, const QPair &range, const int fieldWidth, const bool auto_scale) { QStringList pics; for (int i(range.first); i != range.second; ++i) pics << src.arg(i, fieldWidth, 10, QChar('0')); setPictureSequence(pics, auto_scale); } void DPictureSequenceView::setPictureSequence(const QStringList &sequence, const bool auto_scale) { D_D(DPictureSequenceView); QList pixmapSequence; for (const QString &path : sequence) { pixmapSequence << d->loadPixmap(path); } setPictureSequence(pixmapSequence, auto_scale); } //! //! \brief DPictureSequenceView::setPictureSequence accept a list of pixmap as picture sequence, //! if set auto scale, the pixmap will scale as view size. //! \param sequence //! \param auto_scale //! void DPictureSequenceView::setPictureSequence(const QList &sequence, const bool auto_scale) { D_D(DPictureSequenceView); stop(); d->scene->clear(); d->pictureItemList.clear(); for (QPixmap pixmap : sequence) { if (auto_scale) { pixmap = pixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); } d->pictureItemList << d->scene->addPixmap(pixmap); d->pictureItemList.last()->hide(); } if (!d->pictureItemList.isEmpty()) { d->pictureItemList.first()->show(); } setStyleSheet("background-color:transparent;"); } void DPictureSequenceView::play() { D_D(DPictureSequenceView); d->play(); } void DPictureSequenceView::pause() { D_D(DPictureSequenceView); d->refreshTimer->stop(); } void DPictureSequenceView::stop() { D_D(DPictureSequenceView); d->refreshTimer->stop(); if (d->pictureItemList.count() > d->lastItemPos) d->pictureItemList[d->lastItemPos]->hide(); if (!d->pictureItemList.isEmpty()) d->pictureItemList[0]->show(); d->lastItemPos = 0; } int DPictureSequenceView::speed() const { D_DC(DPictureSequenceView); return d->refreshTimer->interval(); } void DPictureSequenceView::setSpeed(int speed) { D_D(DPictureSequenceView); d->refreshTimer->setInterval(speed); } bool DPictureSequenceView::singleShot() const { D_DC(DPictureSequenceView); return d->singleShot; } void DPictureSequenceView::setSingleShot(bool singleShot) { D_D(DPictureSequenceView); d->singleShot = singleShot; } DWIDGET_END_NAMESPACE #include "moc_dpicturesequenceview.cpp" dtkwidget-2.0.7.2/src/widgets/dpicturesequenceview.h000066400000000000000000000037661325435343100225360ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DPICTURESEQUENCEVIEW_H #define DPICTURESEQUENCEVIEW_H #include "dtkwidget_global.h" #include "dobject.h" #include #include #include DWIDGET_BEGIN_NAMESPACE class DPictureSequenceViewPrivate; class LIBDTKWIDGETSHARED_EXPORT DPictureSequenceView : public QGraphicsView, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(int speed READ speed WRITE setSpeed NOTIFY speedChanged) Q_PROPERTY(bool singleShot READ singleShot WRITE setSingleShot) public: DPictureSequenceView(QWidget *parent = nullptr); void setPictureSequence(const QString &src, const QPair &range, const int fieldWidth = 0, const bool auto_scale = false); void setPictureSequence(const QStringList &sequence, const bool auto_scale = false); void setPictureSequence(const QList &sequence, const bool auto_scale = false); void play(); void pause(); void stop(); int speed() const; void setSpeed(int speed); bool singleShot() const; void setSingleShot(bool singleShot); Q_SIGNALS: void speedChanged(int speed) const; void playEnd() const; private: D_PRIVATE_SLOT(void _q_refreshPicture()) Q_DISABLE_COPY(DPictureSequenceView) D_DECLARE_PRIVATE(DPictureSequenceView) }; DWIDGET_END_NAMESPACE #endif // DPICTURESEQUENCEVIEW_H dtkwidget-2.0.7.2/src/widgets/dplatformwindowhandle.cpp000066400000000000000000000405061325435343100232130ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dplatformwindowhandle.h" #include "dapplication.h" #include "util/dwindowmanagerhelper.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE #define DEFINE_CONST_CHAR(Name) const char _##Name[] = "_d_" #Name DEFINE_CONST_CHAR(useDxcb); DEFINE_CONST_CHAR(redirectContent); DEFINE_CONST_CHAR(netWmStates); DEFINE_CONST_CHAR(windowRadius); DEFINE_CONST_CHAR(borderWidth); DEFINE_CONST_CHAR(borderColor); DEFINE_CONST_CHAR(shadowRadius); DEFINE_CONST_CHAR(shadowOffset); DEFINE_CONST_CHAR(shadowColor); DEFINE_CONST_CHAR(clipPath); DEFINE_CONST_CHAR(frameMask); DEFINE_CONST_CHAR(frameMargins); DEFINE_CONST_CHAR(translucentBackground); DEFINE_CONST_CHAR(enableSystemResize); DEFINE_CONST_CHAR(enableSystemMove); DEFINE_CONST_CHAR(enableBlurWindow); DEFINE_CONST_CHAR(windowBlurAreas); DEFINE_CONST_CHAR(windowBlurPaths); DEFINE_CONST_CHAR(autoInputMaskByClipPath); // functions DEFINE_CONST_CHAR(setWmBlurWindowBackgroundArea); DEFINE_CONST_CHAR(setWmBlurWindowBackgroundPathList); DEFINE_CONST_CHAR(setWmBlurWindowBackgroundMaskImage); DEFINE_CONST_CHAR(setWindowProperty); DEFINE_CONST_CHAR(pluginVersion); static void setWindowProperty(QWindow *window, const char *name, const QVariant &value) { if (!window) return; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) static QFunctionPointer setWindowProperty = qApp->platformFunction(_setWindowProperty); #else constexpr QFunctionPointer setWindowProperty = nullptr; #endif if (!setWindowProperty) { window->setProperty(name, value); return; } reinterpret_cast(setWindowProperty)(window, name, value); } DPlatformWindowHandle::DPlatformWindowHandle(QWindow *window, QObject *parent) : QObject(parent) , m_window(window) { enableDXcbForWindow(window); window->installEventFilter(this); } DPlatformWindowHandle::DPlatformWindowHandle(QWidget *widget, QObject *parent) : QObject(parent) , m_window(Q_NULLPTR) { enableDXcbForWindow(widget); m_window = widget->window()->windowHandle(); if (m_window) m_window->installEventFilter(this); } QString DPlatformWindowHandle::pluginVersion() { QFunctionPointer pv = 0; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) pv = qApp->platformFunction(_pluginVersion); #endif if (Q_UNLIKELY(!pv)) return QString(); return reinterpret_cast(pv)(); } void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget) { if (!DApplication::isDXcbPlatform()) return; QWidget *window = widget->window(); QWindow *handle = window->windowHandle(); if (!handle) { bool save_flag = qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings); qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); window->setAttribute(Qt::WA_NativeWindow); handle = window->windowHandle(); window->setAttribute(Qt::WA_NativeWindow, false); // dxcb version >= 1.1.6 if (!pluginVersion().isEmpty()) { /// TODO: Avoid call parentWidget()->enforceNativeChildren(). qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, save_flag); } Q_ASSERT_X(handle, "DPlatformWindowHandler:", "widget window handle is NULL."); if (Q_UNLIKELY(!handle)) return; } if (handle->property(_useDxcb).toBool()) return; Q_ASSERT_X(!handle->handle(), "DPlatformWindowHandler:", "Must be called before window handle has been created. See also QWidget::windowHandle()"); handle->setProperty(_useDxcb, true); } void DPlatformWindowHandle::enableDXcbForWindow(QWindow *window) { if (!DApplication::isDXcbPlatform()) return; if (window->handle()) { Q_ASSERT_X(window->property(_useDxcb).toBool(), "DPlatformWindowHandler:", "Must be called before window handle has been created. See also QWindow::handle()"); } else { window->setProperty(_useDxcb, true); } } void DPlatformWindowHandle::enableDXcbForWindow(QWidget *widget, bool redirectContent) { enableDXcbForWindow(widget); if (isEnabledDXcb(widget)) { widget->windowHandle()->setProperty(_redirectContent, redirectContent); } } void DPlatformWindowHandle::enableDXcbForWindow(QWindow *window, bool redirectContent) { enableDXcbForWindow(window); if (isEnabledDXcb(window)) { window->setProperty(_redirectContent, redirectContent); } } bool DPlatformWindowHandle::isEnabledDXcb(const QWidget *widget) { return widget->windowHandle() && widget->windowHandle()->property(_useDxcb).toBool(); } bool DPlatformWindowHandle::isEnabledDXcb(const QWindow *window) { return window->property(_useDxcb).toBool(); } bool DPlatformWindowHandle::setWindowBlurAreaByWM(QWidget *widget, const QVector &area) { Q_ASSERT(widget); return widget->windowHandle() && setWindowBlurAreaByWM(widget->windowHandle(), area); } bool DPlatformWindowHandle::setWindowBlurAreaByWM(QWidget *widget, const QList &paths) { Q_ASSERT(widget); return widget->windowHandle() && setWindowBlurAreaByWM(widget->windowHandle(), paths); } inline DPlatformWindowHandle::WMBlurArea operator *(const DPlatformWindowHandle::WMBlurArea &area, qreal scale) { if (qFuzzyCompare(scale, 1.0)) return area; DPlatformWindowHandle::WMBlurArea new_area; new_area.x = qRound64(area.x * scale); new_area.y = qRound64(area.y * scale); new_area.width = qRound64(area.width * scale); new_area.height = qRound64(area.height * scale); new_area.xRadius = qRound64(area.xRadius * scale); new_area.yRaduis = qRound64(area.yRaduis * scale); return new_area; } bool DPlatformWindowHandle::setWindowBlurAreaByWM(QWindow *window, const QVector &area) { if (!window) { return false; } if (isEnabledDXcb(window)) { setWindowProperty(window, _windowBlurAreas, QVariant::fromValue(*(reinterpret_cast*>(&area)))); return true; } QFunctionPointer setWmBlurWindowBackgroundArea = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) setWmBlurWindowBackgroundArea = qApp->platformFunction(_setWmBlurWindowBackgroundArea); #endif if (!setWmBlurWindowBackgroundArea) { qWarning("setWindowBlurAreaByWM is not support"); return false; } QSurfaceFormat format = window->format(); format.setAlphaBufferSize(8); window->setFormat(format); const qreal device_ratio = window->devicePixelRatio(); if (qFuzzyCompare(device_ratio, 1.0)) { return reinterpret_cast&)>(setWmBlurWindowBackgroundArea)(window->winId(), area); } QVector new_areas; new_areas.reserve(area.size()); for (const WMBlurArea &a : area) { new_areas.append(a * device_ratio); } return reinterpret_cast&)>(setWmBlurWindowBackgroundArea)(window->winId(), new_areas); } inline QPainterPath operator *(const QPainterPath &path, qreal scale) { if (qFuzzyCompare(1.0, scale)) return path; QPainterPath new_path = path; for (int i = 0; i < path.elementCount(); ++i) { const QPainterPath::Element &e = path.elementAt(i); new_path.setElementPositionAt(i, qRound(e.x * scale), qRound(e.y * scale)); } return new_path; } bool DPlatformWindowHandle::setWindowBlurAreaByWM(QWindow *window, const QList &paths) { if (!window) { return false; } if (isEnabledDXcb(window)) { setWindowProperty(window, _windowBlurPaths, QVariant::fromValue(paths)); return true; } QFunctionPointer setWmBlurWindowBackgroundPathList = Q_NULLPTR; #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) setWmBlurWindowBackgroundPathList = qApp->platformFunction(_setWmBlurWindowBackgroundPathList); #endif if (!setWmBlurWindowBackgroundPathList) { qWarning("setWindowBlurAreaByWM is not support"); return false; } QSurfaceFormat format = window->format(); format.setAlphaBufferSize(8); window->setFormat(format); const qreal device_ratio = window->devicePixelRatio(); if (qFuzzyCompare(device_ratio, 1.0)) { return reinterpret_cast&)>(setWmBlurWindowBackgroundPathList)(window->winId(), paths); } QList new_paths; new_paths.reserve(paths.size()); for (const QPainterPath &p : paths) { new_paths.append(p * device_ratio); } return reinterpret_cast&)>(setWmBlurWindowBackgroundPathList)(window->winId(), new_paths); } bool DPlatformWindowHandle::connectWindowManagerChangedSignal(QObject *object, std::function slot) { if (object) { return QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::windowManagerChanged, object, slot); } return QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::windowManagerChanged, slot); } bool DPlatformWindowHandle::connectHasBlurWindowChanged(QObject *object, std::function slot) { if (object) { return QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, object, slot); } return QObject::connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasBlurWindowChanged, slot); } bool DPlatformWindowHandle::setWindowBlurAreaByWM(const QVector &area) { return setWindowBlurAreaByWM(m_window, area); } bool DPlatformWindowHandle::setWindowBlurAreaByWM(const QList &paths) { return setWindowBlurAreaByWM(m_window, paths); } int DPlatformWindowHandle::windowRadius() const { return m_window->property(_windowRadius).toInt(); } int DPlatformWindowHandle::borderWidth() const { return m_window->property(_borderWidth).toInt(); } QColor DPlatformWindowHandle::borderColor() const { return qvariant_cast(m_window->property(_borderColor)); } int DPlatformWindowHandle::shadowRadius() const { return m_window->property(_shadowRadius).toInt(); } QPoint DPlatformWindowHandle::shadowOffset() const { return m_window->property(_shadowOffset).toPoint(); } QColor DPlatformWindowHandle::shadowColor() const { return qvariant_cast(m_window->property(_shadowColor)); } QPainterPath DPlatformWindowHandle::clipPath() const { return qvariant_cast(m_window->property(_clipPath)); } QRegion DPlatformWindowHandle::frameMask() const { return qvariant_cast(m_window->property(_frameMask)); } QMargins DPlatformWindowHandle::frameMargins() const { return qvariant_cast(m_window->property(_frameMargins)); } bool DPlatformWindowHandle::translucentBackground() const { return m_window->property(_translucentBackground).toBool(); } bool DPlatformWindowHandle::enableSystemResize() const { return m_window->property(_enableSystemResize).toBool(); } bool DPlatformWindowHandle::enableSystemMove() const { return m_window->property(_enableSystemMove).toBool(); } bool DPlatformWindowHandle::enableBlurWindow() const { return m_window->property(_enableBlurWindow).toBool(); } bool DPlatformWindowHandle::autoInputMaskByClipPath() const { return m_window->property(_autoInputMaskByClipPath).toBool(); } WId DPlatformWindowHandle::realWindowId() const { return qvariant_cast(m_window->property("_d_real_content_window")); } void DPlatformWindowHandle::setWindowRadius(int windowRadius) { setWindowProperty(m_window, _windowRadius, windowRadius); } void DPlatformWindowHandle::setBorderWidth(int borderWidth) { setWindowProperty(m_window, _borderWidth, borderWidth); } void DPlatformWindowHandle::setBorderColor(const QColor &borderColor) { setWindowProperty(m_window, _borderColor, QVariant::fromValue(borderColor)); } void DPlatformWindowHandle::setShadowRadius(int shadowRadius) { setWindowProperty(m_window, _shadowRadius, shadowRadius); } void DPlatformWindowHandle::setShadowOffset(const QPoint &shadowOffset) { setWindowProperty(m_window, _shadowOffset, shadowOffset); } void DPlatformWindowHandle::setShadowColor(const QColor &shadowColor) { setWindowProperty(m_window, _shadowColor, QVariant::fromValue(shadowColor)); } void DPlatformWindowHandle::setClipPath(const QPainterPath &clipPath) { setWindowProperty(m_window, _clipPath, QVariant::fromValue(clipPath)); } void DPlatformWindowHandle::setFrameMask(const QRegion &frameMask) { setWindowProperty(m_window, _frameMask, QVariant::fromValue(frameMask)); } void DPlatformWindowHandle::setTranslucentBackground(bool translucentBackground) { setWindowProperty(m_window, _translucentBackground, translucentBackground); } void DPlatformWindowHandle::setEnableSystemResize(bool enableSystemResize) { setWindowProperty(m_window, _enableSystemResize, enableSystemResize); } void DPlatformWindowHandle::setEnableSystemMove(bool enableSystemMove) { setWindowProperty(m_window, _enableSystemMove, enableSystemMove); } void DPlatformWindowHandle::setEnableBlurWindow(bool enableBlurWindow) { setWindowProperty(m_window, _enableBlurWindow, enableBlurWindow); } void DPlatformWindowHandle::setAutoInputMaskByClipPath(bool autoInputMaskByClipPath) { setWindowProperty(m_window, _autoInputMaskByClipPath, autoInputMaskByClipPath); } bool DPlatformWindowHandle::eventFilter(QObject *obj, QEvent *event) { if (obj == m_window) { if (event->type() == QEvent::DynamicPropertyChange) { QDynamicPropertyChangeEvent *e = static_cast(event); if (e->propertyName() == _windowRadius) { Q_EMIT windowRadiusChanged(); } else if (e->propertyName() == _borderWidth) { Q_EMIT borderWidthChanged(); } else if (e->propertyName() == _borderColor) { Q_EMIT borderColorChanged(); } else if (e->propertyName() == _shadowRadius) { Q_EMIT shadowRadiusChanged(); } else if (e->propertyName() == _shadowOffset) { Q_EMIT shadowOffsetChanged(); } else if (e->propertyName() == _shadowColor) { Q_EMIT shadowColorChanged(); } else if (e->propertyName() == _clipPath) { Q_EMIT clipPathChanged(); } else if (e->propertyName() == _frameMask) { Q_EMIT frameMaskChanged(); } else if (e->propertyName() == _frameMargins) { Q_EMIT frameMarginsChanged(); } else if (e->propertyName() == _translucentBackground) { Q_EMIT translucentBackgroundChanged(); } else if (e->propertyName() == _enableSystemResize) { Q_EMIT enableSystemResizeChanged(); } else if (e->propertyName() == _enableSystemMove) { Q_EMIT enableSystemMoveChanged(); } else if (e->propertyName() == _enableBlurWindow) { Q_EMIT enableBlurWindowChanged(); } else if (e->propertyName() == _autoInputMaskByClipPath) { Q_EMIT autoInputMaskByClipPathChanged(); } } } return false; } DWIDGET_END_NAMESPACE QT_BEGIN_NAMESPACE QDebug operator<<(QDebug deg, const DPlatformWindowHandle::WMBlurArea &area) { QDebugStateSaver saver(deg); Q_UNUSED(saver) deg.setAutoInsertSpaces(true); deg << "x:" << area.x << "y:" << area.y << "width:" << area.width << "height:" << area.height << "xRadius:" << area.xRadius << "yRadius:" << area.yRaduis; return deg; } QT_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dplatformwindowhandle.h000066400000000000000000000144711325435343100226620ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DPLATFORMWINDOWHANDLE_H #define DPLATFORMWINDOWHANDLE_H #include "dtkwidget_global.h" #include #include #include #include #include QT_BEGIN_NAMESPACE class QWindow; class QWidget; QT_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DPlatformWindowHandle : public QObject { Q_OBJECT Q_PROPERTY(int windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged) Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged) Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged) Q_PROPERTY(int shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY shadowRadiusChanged) Q_PROPERTY(QPoint shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged) Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged) Q_PROPERTY(QPainterPath clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged) Q_PROPERTY(QRegion frameMask READ frameMask WRITE setFrameMask NOTIFY frameMaskChanged) Q_PROPERTY(QMargins frameMargins READ frameMargins NOTIFY frameMarginsChanged) Q_PROPERTY(bool translucentBackground READ translucentBackground WRITE setTranslucentBackground NOTIFY translucentBackgroundChanged) Q_PROPERTY(bool enableSystemResize READ enableSystemResize WRITE setEnableSystemResize NOTIFY enableSystemResizeChanged) Q_PROPERTY(bool enableSystemMove READ enableSystemMove WRITE setEnableSystemMove NOTIFY enableSystemMoveChanged) Q_PROPERTY(bool enableBlurWindow READ enableBlurWindow WRITE setEnableBlurWindow NOTIFY enableBlurWindowChanged) Q_PROPERTY(bool autoInputMaskByClipPath READ autoInputMaskByClipPath WRITE setAutoInputMaskByClipPath NOTIFY autoInputMaskByClipPathChanged) Q_PROPERTY(WId realWindowId READ realWindowId CONSTANT) public: explicit DPlatformWindowHandle(QWindow *window, QObject *parent = 0); explicit DPlatformWindowHandle(QWidget *widget, QObject *parent = 0); static QString pluginVersion(); static void enableDXcbForWindow(QWidget *widget); static void enableDXcbForWindow(QWindow *window); static void enableDXcbForWindow(QWidget *widget, bool redirectContent); static void enableDXcbForWindow(QWindow *window, bool redirectContent); static bool isEnabledDXcb(const QWidget *widget); static bool isEnabledDXcb(const QWindow *window); struct WMBlurArea { qint32 x = 0; qint32 y = 0; qint32 width = 0; qint32 height = 0; qint32 xRadius = 0; qint32 yRaduis = 0; }; static bool setWindowBlurAreaByWM(QWidget *widget, const QVector &area); static bool setWindowBlurAreaByWM(QWidget *widget, const QList &paths); static bool setWindowBlurAreaByWM(QWindow *window, const QVector &area); static bool setWindowBlurAreaByWM(QWindow *window, const QList &paths); static bool connectWindowManagerChangedSignal(QObject *object, std::function slot); static bool connectHasBlurWindowChanged(QObject *object, std::function slot); bool setWindowBlurAreaByWM(const QVector &area); bool setWindowBlurAreaByWM(const QList &paths); int windowRadius() const; int borderWidth() const; QColor borderColor() const; int shadowRadius() const; QPoint shadowOffset() const; QColor shadowColor() const; QPainterPath clipPath() const; QRegion frameMask() const; QMargins frameMargins() const; bool translucentBackground() const; bool enableSystemResize() const; bool enableSystemMove() const; bool enableBlurWindow() const; bool autoInputMaskByClipPath() const; WId realWindowId() const; public Q_SLOTS: void setWindowRadius(int windowRadius); void setBorderWidth(int borderWidth); void setBorderColor(const QColor &borderColor); void setShadowRadius(int shadowRadius); void setShadowOffset(const QPoint &shadowOffset); void setShadowColor(const QColor &shadowColor); void setClipPath(const QPainterPath &clipPath); void setFrameMask(const QRegion &frameMask); void setTranslucentBackground(bool translucentBackground); void setEnableSystemResize(bool enableSystemResize); void setEnableSystemMove(bool enableSystemMove); void setEnableBlurWindow(bool enableBlurWindow); void setAutoInputMaskByClipPath(bool autoInputMaskByClipPath); Q_SIGNALS: void frameMarginsChanged(); void windowRadiusChanged(); void borderWidthChanged(); void borderColorChanged(); void shadowRadiusChanged(); void shadowOffsetChanged(); void shadowColorChanged(); void clipPathChanged(); void frameMaskChanged(); void translucentBackgroundChanged(); void enableSystemResizeChanged(); void enableSystemMoveChanged(); void enableBlurWindowChanged(); void autoInputMaskByClipPathChanged(); protected: bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; private: QWindow *m_window; }; inline DPlatformWindowHandle::WMBlurArea dMakeWMBlurArea(quint32 x, quint32 y, quint32 width, quint32 height, quint32 xr = 0, quint32 yr = 0) { DPlatformWindowHandle::WMBlurArea a; a.x = x; a.y = y; a.width = width; a.height = height; a.xRadius = xr; a.yRaduis = yr; return a; } DWIDGET_END_NAMESPACE QT_BEGIN_NAMESPACE DWIDGET_USE_NAMESPACE QDebug operator<<(QDebug deg, const DPlatformWindowHandle::WMBlurArea &area); QT_END_NAMESPACE Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(QRegion) Q_DECLARE_METATYPE(QMargins) #endif // DPLATFORMWINDOWHANDLE_H dtkwidget-2.0.7.2/src/widgets/dpushbutton.cpp000066400000000000000000000055511325435343100211770ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dpushbutton.h" #include "private/dpushbutton_p.h" DWIDGET_BEGIN_NAMESPACE DPushButton::DPushButton(QWidget *parent) : QPushButton(parent) , DObject(*new DPushButtonPrivate(this)) { } DPushButton::DPushButton(const QString &normalIcon, const QString &hoverIcon, const QString &pressIcon, QWidget *parent) : DPushButton(parent) { setNormalIcon(normalIcon); setHoverIcon(hoverIcon); setPressIcon(pressIcon); } const QString DPushButton::normalIcon() const { D_DC(DPushButton); return d->normalIconPath; } const QString DPushButton::hoverIcon() const { D_DC(DPushButton); return d->hoverIconPath; } const QString DPushButton::pressIcon() const { D_DC(DPushButton); return d->pressIconPath; } void DPushButton::setNormalIcon(const QString &normalIcon) { D_D(DPushButton); setNormalIcon(QIcon(normalIcon)); d->normalIconPath = normalIcon; } void DPushButton::setHoverIcon(const QString &hoverIcon) { D_D(DPushButton); setHoverIcon(QIcon(hoverIcon)); d->hoverIconPath = hoverIcon; } void DPushButton::setPressIcon(const QString &pressIcon) { D_D(DPushButton); setPressIcon(QIcon(pressIcon)); d->pressIconPath = pressIcon; } void DPushButton::setNormalIcon(const QIcon &normalIcon) { D_D(DPushButton); d->normalIconPath.clear(); d->normalIcon = QIcon(normalIcon); setIcon(d->normalIcon); } void DPushButton::setHoverIcon(const QIcon &hoverIcon) { D_D(DPushButton); d->hoverIconPath.clear(); d->hoverIcon = QIcon(hoverIcon); } void DPushButton::setPressIcon(const QIcon &pressIcon) { D_D(DPushButton); d->pressIconPath.clear(); d->pressIcon = QIcon(pressIcon); } void DPushButton::enterEvent(QEvent *e) { D_D(DPushButton); setIcon(d->hoverIcon); QPushButton::enterEvent(e); } void DPushButton::leaveEvent(QEvent *e) { D_D(DPushButton); setIcon(d->normalIcon); QPushButton::leaveEvent(e); } void DPushButton::mousePressEvent(QMouseEvent *e) { D_D(DPushButton); setIcon(d->pressIcon); QPushButton::mousePressEvent(e); } DPushButtonPrivate::DPushButtonPrivate(DPushButton *qq) : DObjectPrivate(qq) { } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dpushbutton.h000066400000000000000000000041251325435343100206400ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DICONBUTTON_H #define DICONBUTTON_H #include "dtkwidget_global.h" #include "dobject.h" #include #include DWIDGET_BEGIN_NAMESPACE class DPushButtonPrivate; class LIBDTKWIDGETSHARED_EXPORT DPushButton : public QPushButton, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(QString normalIcon READ normalIcon WRITE setNormalIcon DESIGNABLE true) Q_PROPERTY(QString hoverIcon READ hoverIcon WRITE setHoverIcon DESIGNABLE true) Q_PROPERTY(QString pressIcon READ pressIcon WRITE setPressIcon DESIGNABLE true) public: explicit DPushButton(QWidget *parent = 0); DPushButton(const QString &normalIcon, const QString &hoverIcon, const QString &pressIcon, QWidget *parent = 0); const QString normalIcon() const; const QString hoverIcon() const; const QString pressIcon() const; public Q_SLOTS: void setNormalIcon(const QString &normalIcon); void setHoverIcon(const QString &hoverIcon); void setPressIcon(const QString &pressIcon); void setNormalIcon(const QIcon &normalIcon); void setHoverIcon(const QIcon &hoverIcon); void setPressIcon(const QIcon &pressIcon); protected: void enterEvent(QEvent *e) Q_DECL_OVERRIDE; void leaveEvent(QEvent *e) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DPushButton) }; DWIDGET_END_NAMESPACE #endif // DICONBUTTON_H dtkwidget-2.0.7.2/src/widgets/dscrollarea.cpp000066400000000000000000000106501325435343100211070ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include "dscrollarea.h" #include "dthememanager.h" #include "dscrollbar.h" #include "private/dscrollarea_p.h" DWIDGET_BEGIN_NAMESPACE DScrollAreaPrivate::DScrollAreaPrivate(DScrollArea *qq): DObjectPrivate(qq), autoHideScrollBar(false), vBar(new DScrollBar), hBar(new DScrollBar), scrollBarAnimation(0), timer(0) { } DScrollAreaPrivate::~DScrollAreaPrivate() { vBar->deleteLater(); hBar->deleteLater(); if(scrollBarAnimation) scrollBarAnimation->deleteLater(); if(timer) timer->deleteLater(); } void DScrollAreaPrivate::init() { Q_Q(DScrollArea); q->setVerticalScrollBar(vBar); q->setHorizontalScrollBar(hBar); QObject::connect(vBar, &DScrollBar::valueChanged, q, [q, this]{ q->showScrollBar(vBar); }); QObject::connect(hBar, &DScrollBar::valueChanged, q, [q, this]{ q->showScrollBar(hBar); }); } DScrollArea::DScrollArea(QWidget *parent) : QScrollArea(parent), DObject(*new DScrollAreaPrivate(this)) { DThemeManager::registerWidget(this); d_func()->init(); } bool DScrollArea::autoHideScrollBar() const { Q_D(const DScrollArea); return d->autoHideScrollBar; } void DScrollArea::setAutoHideScrollBar(bool autoHideScrollBar) { Q_D(DScrollArea); if (d->autoHideScrollBar == autoHideScrollBar) return; d->autoHideScrollBar = autoHideScrollBar; if(autoHideScrollBar){ if(!d->scrollBarAnimation) d->scrollBarAnimation = new QPropertyAnimation(this, "windowOpacity"); if(!d->timer) d->timer = new QTimer(this); d->scrollBarAnimation->setDuration(300); d->timer->setSingleShot(true); d->vBar->hide(); d->hBar->hide(); connect(d->timer, &QTimer::timeout, [&]{ if(d->vBar->isVisible()) hideScrollBar(d->vBar); if(d->hBar->isVisible()) hideScrollBar(d->hBar); }); }else{ if(d->scrollBarAnimation) d->scrollBarAnimation->deleteLater(); if(d->timer) d->timer->deleteLater(); showScrollBar(d->vBar); showScrollBar(d->hBar); } Q_EMIT autoHideScrollBarChanged(autoHideScrollBar); } void DScrollArea::hideScrollBar(QScrollBar *bar) { Q_D(DScrollArea); if(bar->isHidden()) return; if(d->scrollBarAnimation){ connect(d->scrollBarAnimation, &QPropertyAnimation::finished, bar, &DScrollBar::hide); connect(d->scrollBarAnimation, &QPropertyAnimation::finished, bar, &DScrollBar::hide); d->scrollBarAnimation->setStartValue(1.0); d->scrollBarAnimation->setEndValue(0.0); d->scrollBarAnimation->start(); }else{ bar->hide(); } } void DScrollArea::showScrollBar(QScrollBar *bar) { Q_D(DScrollArea); if(bar->isVisible()) return; if(bar == d->vBar && verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff) d->vBar->show(); else if(bar == d->hBar && horizontalScrollBarPolicy() != Qt::ScrollBarAlwaysOff) d->hBar->show(); if(d->scrollBarAnimation){ disconnect(d->scrollBarAnimation, &QPropertyAnimation::finished, bar, &DScrollBar::hide); disconnect(d->scrollBarAnimation, &QPropertyAnimation::finished, bar, &DScrollBar::hide); d->scrollBarAnimation->setStartValue(1.0); d->scrollBarAnimation->setEndValue(0.0); d->scrollBarAnimation->start(); d->timer->start(1000); } } DScrollArea::DScrollArea(DScrollAreaPrivate &dd, QWidget *parent): QScrollArea(parent), DObject(dd) { DThemeManager::registerWidget(this); d_func()->init(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dscrollarea.h000066400000000000000000000031371325435343100205560ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSCROLLAREA_H #define DSCROLLAREA_H #include #include "dtkwidget_global.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE class DScrollBar; class DScrollAreaPrivate; class LIBDTKWIDGETSHARED_EXPORT DScrollArea : public QScrollArea, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(bool autoHideScrollBar READ autoHideScrollBar WRITE setAutoHideScrollBar NOTIFY autoHideScrollBarChanged) public: explicit DScrollArea(QWidget *parent = 0); bool autoHideScrollBar() const; public Q_SLOTS: void setAutoHideScrollBar(bool autoHideScrollBar); Q_SIGNALS: void autoHideScrollBarChanged(bool autoHideScrollBar); private Q_SLOTS: void hideScrollBar(QScrollBar *bar); void showScrollBar(QScrollBar *bar); protected: DScrollArea(DScrollAreaPrivate &dd, QWidget *parent = 0); private: D_DECLARE_PRIVATE(DScrollArea) }; DWIDGET_END_NAMESPACE #endif // DSCROLLAREA_H dtkwidget-2.0.7.2/src/widgets/dscrollbar.cpp000066400000000000000000000061331325435343100207440ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dscrollbar.h" #include "dthememanager.h" #include "private/dscrollbar_p.h" #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE DScrollBarPrivate::DScrollBarPrivate(DScrollBar *qq) : DObjectPrivate(qq) { } void DScrollBarPrivate::init() { D_Q(DScrollBar); timer = new QTimer(q); opacityTimer = new QTimer(q); timer->setInterval(1000); timer->setSingleShot(true); q->connect(timer, SIGNAL(timeout()), q, SLOT(_q_hidden())); q->connect(opacityTimer, SIGNAL(timeout()), q, SLOT(_q_updateOpacity())); q->connect(q, &DScrollBar::valueChanged, q, [this] { timer->start(); opacityTimer->stop(); setOpacity(1); }); } void DScrollBarPrivate::setOpacity(qreal opacity) { D_Q(DScrollBar); if (qAbs(this->opacity - opacity) < 0.001) { return; } this->opacity = opacity; this->canPaint = false; q->update(); } void DScrollBarPrivate::_q_hidden() { timer->stop(); opacityTimer->start(50); } void DScrollBarPrivate::_q_updateOpacity() { if (opacity < 0.01) { opacityTimer->stop(); } else { setOpacity(opacity - 0.05); } } DScrollBar::DScrollBar(QWidget *parent) : QScrollBar(parent) , DObject(*new DScrollBarPrivate(this)) { DThemeManager::registerWidget(this); d_func()->init(); } bool DScrollBar::autoHide() const { D_DC(DScrollBar); return d->autoHide; } void DScrollBar::setAutoHide(bool autoHide) { D_D(DScrollBar); if (d->autoHide == autoHide) return; d->autoHide = autoHide; Q_EMIT autoHideChanged(autoHide); update(); } void DScrollBar::enterEvent(QEvent *event) { D_D(DScrollBar); d->timer->stop(); d->opacityTimer->stop(); d->setOpacity(1); QScrollBar::enterEvent(event); } void DScrollBar::leaveEvent(QEvent *event) { D_DC(DScrollBar); d->timer->start(1000); QScrollBar::leaveEvent(event); } void DScrollBar::paintEvent(QPaintEvent *event) { D_D(DScrollBar); if (d->canPaint || !d->autoHide) { return QScrollBar::paintEvent(event); } QPixmap pixmap; QPainter painter(this); d->canPaint = true; setAttribute(Qt::WA_WState_InPaintEvent, false); pixmap = grab(); painter.setOpacity(d->opacity); painter.drawPixmap(QPoint(0, 0), pixmap); } DWIDGET_END_NAMESPACE #include "moc_dscrollbar.cpp" dtkwidget-2.0.7.2/src/widgets/dscrollbar.h000066400000000000000000000031421325435343100204060ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSCROLLBAR_H #define DSCROLLBAR_H #include #include "dtkwidget_global.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE class DScrollBarPrivate; class LIBDTKWIDGETSHARED_EXPORT DScrollBar : public QScrollBar, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(bool autoHide READ autoHide WRITE setAutoHide NOTIFY autoHideChanged) public: explicit DScrollBar(QWidget *parent = 0); bool autoHide() const; public Q_SLOTS: void setAutoHide(bool autoHide); Q_SIGNALS: void autoHideChanged(bool autoHide); protected: void enterEvent(QEvent *event) Q_DECL_OVERRIDE; void leaveEvent(QEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(DScrollBar) D_DECLARE_PRIVATE(DScrollBar) D_PRIVATE_SLOT(void _q_hidden()) D_PRIVATE_SLOT(void _q_updateOpacity()) }; DWIDGET_END_NAMESPACE #endif // DSCROLLBAR_H dtkwidget-2.0.7.2/src/widgets/dsearchedit.cpp000066400000000000000000000133031325435343100210710ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dsearchedit.h" #include "dthememanager.h" #include #include #include #include #include #include #include #include DWIDGET_USE_NAMESPACE DSearchEdit::DSearchEdit(QWidget *parent) : QFrame(parent) { DThemeManager::registerWidget(this); initInsideFrame(); m_searchBtn = new QLabel; m_searchBtn->setObjectName("SearchIcon"); m_searchBtn->setFixedSize(16, 16); m_clearBtn = new DImageButton; m_clearBtn->setObjectName("ClearIcon"); m_clearBtn->hide(); m_edt = new QLineEdit; m_edt->setObjectName("Edit"); m_placeHolder = new QLabel; m_placeHolder->setObjectName("PlaceHolder"); m_animation = new QPropertyAnimation(m_edt, "minimumWidth"); m_size = QSize(m_searchBtn->sizeHint().width() + m_edt->sizeHint().width() + m_clearBtn->sizeHint().width() + 6, qMax(m_searchBtn->sizeHint().height(), m_edt->sizeHint().height())); m_edt->setFixedWidth(0); m_edt->installEventFilter(this); QHBoxLayout *layout = new QHBoxLayout(m_insideFrame); layout->addStretch(); layout->addWidget(m_searchBtn); layout->setAlignment(m_searchBtn, Qt::AlignCenter); layout->addWidget(m_placeHolder); layout->setAlignment(m_placeHolder, Qt::AlignCenter); layout->addWidget(m_edt); layout->setAlignment(m_edt, Qt::AlignCenter); layout->addStretch(); layout->addWidget(m_clearBtn); layout->setAlignment(m_clearBtn, Qt::AlignCenter); layout->setSpacing(0); layout->setContentsMargins(3, 0, 3, 0); setAutoFillBackground(true); setFocusPolicy(Qt::StrongFocus); connect(m_clearBtn, &DImageButton::clicked, m_edt, static_cast(&QLineEdit::setFocus)); connect(m_clearBtn, &DImageButton::clicked, this, &DSearchEdit::clear); connect(m_edt, &QLineEdit::textChanged, [this] {m_clearBtn->setVisible(!m_edt->text().isEmpty());}); connect(m_edt, &QLineEdit::textChanged, this, &DSearchEdit::textChanged, Qt::DirectConnection); connect(m_edt, &QLineEdit::editingFinished, this, &DSearchEdit::editingFinished, Qt::DirectConnection); connect(m_edt, &QLineEdit::returnPressed, this, &DSearchEdit::returnPressed, Qt::DirectConnection); // connect(m_searchBtn, &DImageButton::clicked, this, &DSearchEdit::toEditMode); } DSearchEdit::~DSearchEdit() { m_animation->deleteLater(); } const QString DSearchEdit::text() const { return m_edt->text(); } void DSearchEdit::mousePressEvent(QMouseEvent *e) { if (e->button() != Qt::LeftButton) return QFrame::mousePressEvent(e); toEditMode(); e->accept(); } void DSearchEdit::mouseReleaseEvent(QMouseEvent *e) { e->accept(); } bool DSearchEdit::eventFilter(QObject *o, QEvent *e) { if (o == m_edt && e->type() == QEvent::FocusOut && m_edt->text().isEmpty()) { auto fe = dynamic_cast(e); if (fe && fe->reason() != Qt::PopupFocusReason) { m_animation->stop(); m_animation->setStartValue(m_edt->width()); m_animation->setEndValue(0); m_animation->setEasingCurve(m_hideCurve); m_animation->start(); connect(m_animation, &QPropertyAnimation::finished, m_placeHolder, &QLabel::show); } } if (o == m_edt) { if (e->type() == QEvent::FocusOut) { Q_EMIT focusOut(); } if (e->type() == QEvent::FocusIn) { Q_EMIT focusIn(); } } return QFrame::eventFilter(o, e); } QLineEdit *DSearchEdit::getLineEdit() const { return m_edt; } void DSearchEdit::toEditMode() { // already in edit mode if (!m_placeHolder->isVisible()) { return; } disconnect(m_animation, &QPropertyAnimation::finished, m_placeHolder, &QLabel::show); m_animation->stop(); m_animation->setStartValue(0); m_animation->setEndValue(m_size.width() - m_searchBtn->width() - 6); // left + right margins = 6 m_animation->setEasingCurve(m_showCurve); m_animation->start(); m_placeHolder->hide(); m_edt->setFocus(); } //Bypassing the problem here //qss can't draw box-shadow void DSearchEdit::initInsideFrame() { m_insideFrame = new QFrame(this); m_insideFrame->raise(); m_insideFrame->setObjectName("DEditInsideFrame"); QHBoxLayout *insideLayout = new QHBoxLayout(this); insideLayout->setContentsMargins(0, 0, 0, 1); insideLayout->setSpacing(0); insideLayout->addWidget(m_insideFrame); } void DSearchEdit::resizeEvent(QResizeEvent *e) { m_size = e->size(); m_edt->setFixedHeight(m_size.height()); } bool DSearchEdit::event(QEvent *e) { if (e->type() == QEvent::FocusIn) { const QFocusEvent *event = static_cast(e); if (event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason || event->reason() == Qt::OtherFocusReason || event->reason() == Qt::ShortcutFocusReason) { toEditMode(); } } return QFrame::event(e); } dtkwidget-2.0.7.2/src/widgets/dsearchedit.h000066400000000000000000000046431325435343100205450ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSEARCHEDIT_H #define DSEARCHEDIT_H #include #include #include #include #include "dtkwidget_global.h" #include "dimagebutton.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DSearchEdit : public QFrame { Q_OBJECT public: explicit DSearchEdit(QWidget *parent = 0); ~DSearchEdit(); QSize sizeHint() const {return m_size;} QSize minimumSizeHint() const {return m_size;} const QString text() const; void mousePressEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e); bool eventFilter(QObject *o, QEvent *e); inline void setAniDuration(const int duration) {m_animation->setDuration(duration);} inline void setAniShowCurve(const QEasingCurve curve) {m_showCurve = curve;} inline void setAniHideCurve(const QEasingCurve curve) {m_hideCurve = curve;} QLineEdit *getLineEdit() const; public Q_SLOTS: void setText(const QString & text) {if (m_edt) m_edt->setText(text);} inline void clear() {m_edt->clear();} inline void setPlaceHolder(const QString &text) {m_placeHolder->setText(text);} Q_SIGNALS: void textChanged(); void returnPressed(); void editingFinished(); void focusOut(); void focusIn(); private Q_SLOTS: void toEditMode(); private: void initInsideFrame(); void resizeEvent(QResizeEvent *e); bool event(QEvent *e); private: QSize m_size; QLineEdit *m_edt; QLabel *m_searchBtn; DImageButton *m_clearBtn; QLabel *m_placeHolder; QFrame *m_insideFrame = NULL; QPropertyAnimation *m_animation; QEasingCurve m_showCurve = QEasingCurve::OutCubic; QEasingCurve m_hideCurve = QEasingCurve::InCubic; }; DWIDGET_END_NAMESPACE #endif // DSEARCHEDIT_H dtkwidget-2.0.7.2/src/widgets/dsegmentedcontrol.cpp000066400000000000000000000156541325435343100223450ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dsegmentedcontrol.h" #include #include #include #include #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE DSegmentedHighlight::DSegmentedHighlight(QWidget *parent) : QToolButton(parent) { } DSegmentedControl::DSegmentedControl(QWidget *parent) : QFrame(parent), m_highlight(new DSegmentedHighlight(this)), m_hLayout(new QHBoxLayout(this)), m_highlightMoveAnimation(new QPropertyAnimation(m_highlight, "geometry", this)), m_currentIndex(-1) { setObjectName("DSegmentedControl"); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_hLayout->setSpacing(0); m_hLayout->setMargin(0); m_hLayout->setObjectName("TabBar"); m_highlight->setObjectName("Highlight"); m_highlight->installEventFilter(this); DThemeManager::registerWidget(this); m_highlightMoveAnimation->setDuration(100); m_highlightMoveAnimation->setEasingCurve(QEasingCurve::InCubic); } int DSegmentedControl::count() const { return m_tabList.count(); } const DSegmentedHighlight *DSegmentedControl::highlight() const { return m_highlight; } int DSegmentedControl::currentIndex() const { return m_currentIndex; } QToolButton *DSegmentedControl::at(int index) const { return m_tabList[index]; } QString DSegmentedControl::getText(int index) const { const QToolButton *button = at(index); if(button){ return button->text(); } return ""; } QIcon DSegmentedControl::getIcon(int index) const { return at(index)->icon(); } int DSegmentedControl::animationDuration() const { return m_highlightMoveAnimation->duration(); } int DSegmentedControl::indexByTitle(const QString &title) const { int i=0; Q_FOREACH (QToolButton *button, m_tabList) { if(button->text() == title) return i; ++i; } return -1; } QEasingCurve::Type DSegmentedControl::animationType() const { return m_highlightMoveAnimation->easingCurve().type(); } int DSegmentedControl::addSegmented(const QString &title) { insertSegmented(m_hLayout->count(), title); return m_hLayout->count()-1; } int DSegmentedControl::addSegmented(const QIcon &icon, const QString &title) { insertSegmented(m_hLayout->count(), icon, title); return m_hLayout->count()-1; } void DSegmentedControl::addSegmented(const QStringList &titleList) { Q_FOREACH (const QString &title, titleList) { addSegmented(title); } } void DSegmentedControl::addSegmented(const QList &iconList, const QStringList &titleList) { for(int i=0;isetObjectName("Segmented"); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); button->setText(title); button->setIcon(icon); connect(button, &QToolButton::clicked, this, &DSegmentedControl::buttonClicked); m_hLayout->insertWidget(index, button); if(m_currentIndex == -1){ setCurrentIndex(0); } button->installEventFilter(this); } void DSegmentedControl::removeSegmented(int index) { if(index == m_currentIndex) setCurrentIndex(-1); delete m_hLayout->takeAt(index); QToolButton *button = at(index); m_tabList.removeAt(index); if(button) button->deleteLater(); } void DSegmentedControl::clear() { for(int i=0; itakeAt(i); QToolButton *button = at(i); if(button) button->deleteLater(); } m_tabList.clear(); } bool DSegmentedControl::setCurrentIndex(int currentIndex) { if(currentIndex == m_currentIndex) return true; if(currentIndex<0||currentIndex>count()-1){ qErrnoWarning("index range over!"); return false; } m_currentIndex = currentIndex; Q_FOREACH (QToolButton *button, m_tabList) { button->setEnabled(true); } at(currentIndex)->setFocus(); at(currentIndex)->setEnabled(false); updateHighlightGeometry(); Q_EMIT currentChanged(currentIndex); Q_EMIT currentTitleChanged(at(currentIndex)->text()); return true; } bool DSegmentedControl::setCurrentIndexByTitle(const QString &title) { return setCurrentIndex(indexByTitle(title)); } void DSegmentedControl::setText(int index, const QString &title) { at(index)->setText(title); } void DSegmentedControl::setIcon(int index, const QIcon &icon) { at(index)->setIcon(icon); } void DSegmentedControl::setAnimationDuration(int animationDuration) { m_highlightMoveAnimation->setDuration(animationDuration); } void DSegmentedControl::setAnimationType(QEasingCurve::Type animationType) { m_highlightMoveAnimation->setEasingCurve(animationType); } bool DSegmentedControl::eventFilter(QObject *obj, QEvent *e) { if(m_currentIndex < 0) return false; QWidget *w = at(m_currentIndex); if(obj == m_highlight){ if(e->type() == QEvent::Move){ updateHighlightGeometry(false); } }else if(obj == w){ if(e->type() == QEvent::Resize){ updateHighlightGeometry(false); } } return false; } void DSegmentedControl::updateHighlightGeometry(bool animation) { if(m_currentIndex<0) return; QRect tmp = at(m_currentIndex)->geometry(); if(m_currentIndex==0){ tmp.setX(0); tmp.setWidth(tmp.width()+1); }else if(m_currentIndex == count()-1){ tmp.setWidth(tmp.width()+1); } tmp.setY(0); if(m_highlight->geometry() == tmp) return; if(animation){ m_highlightMoveAnimation->setStartValue(m_highlight->geometry()); m_highlightMoveAnimation->setEndValue(tmp); m_highlightMoveAnimation->start(); }else{ m_highlight->setFixedSize(tmp.size()); m_highlight->move(tmp.topLeft()); } } void DSegmentedControl::buttonClicked() { int i = m_tabList.indexOf(qobject_cast(sender())); if(i>=0){ setCurrentIndex(i); } } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dsegmentedcontrol.h000066400000000000000000000062201325435343100217770ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSEGMENTEDCONTROL_H #define DSEGMENTEDCONTROL_H #include #include #include #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DSegmentedHighlight : public QToolButton { Q_OBJECT public: explicit DSegmentedHighlight(QWidget *parent = 0); }; class LIBDTKWIDGETSHARED_EXPORT DSegmentedControl : public QFrame { Q_OBJECT Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged) Q_PROPERTY(int count READ count) Q_PROPERTY(int animationDuration READ animationDuration WRITE setAnimationDuration) Q_PROPERTY(QEasingCurve::Type animationType READ animationType WRITE setAnimationType) public: explicit DSegmentedControl(QWidget *parent = 0); int count() const; const DSegmentedHighlight *highlight() const; int currentIndex() const; QToolButton *at(int index) const; QString getText(int index) const; QIcon getIcon(int index) const; int animationDuration() const; int indexByTitle(const QString &title) const; QEasingCurve::Type animationType() const; public Q_SLOTS: int addSegmented(const QString &title); int addSegmented(const QIcon &icon, const QString &title); void addSegmented(const QStringList &titleList); void addSegmented(const QList &iconList, const QStringList &titleList); void insertSegmented(int index, const QString &title); void insertSegmented(int index, const QIcon &icon, const QString &title); void removeSegmented(int index); void clear(); bool setCurrentIndex(int currentIndex); bool setCurrentIndexByTitle(const QString &title); void setText(int index, const QString &title); void setIcon(int index, const QIcon &icon); void setAnimationDuration(int animationDuration); void setAnimationType(QEasingCurve::Type animationType); private: DSegmentedHighlight *m_highlight; QHBoxLayout *m_hLayout; QPropertyAnimation *m_highlightMoveAnimation; int m_currentIndex; QList m_tabList; protected: bool eventFilter(QObject *, QEvent *); private Q_SLOTS: void updateHighlightGeometry(bool animation = true); void buttonClicked(); Q_SIGNALS: void currentChanged(int index); void currentTitleChanged(QString title); void animationDurationChanged(int animationDuration); }; DWIDGET_END_NAMESPACE #endif // DSEGMENTEDCONTROL_H dtkwidget-2.0.7.2/src/widgets/dseparatorhorizontal.cpp000066400000000000000000000034421325435343100230730ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dseparatorhorizontal.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DSeparatorHorizontal * \brief The DSeparatorHorizontal class provides an horizontal separator. * * DSeparatorHorizontal has fixed two pixels in height. */ /*! * \brief DSeparatorHorizontal::DSeparatorHorizontal constructs an instance of DSeparatorHorizontal. * \param parent is passed to QWidget constructor. */ DSeparatorHorizontal::DSeparatorHorizontal(QWidget *parent) : QWidget(parent) { DThemeManager::registerWidget(this); this->setFixedHeight(2); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_topRec = new QWidget(this); m_topRec->setObjectName("DSeparatorTopRec"); m_bottomRec = new QWidget(this); m_bottomRec->setObjectName("DSeparatorBottomRec"); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setMargin(0); mainLayout->setSpacing(0); mainLayout->addStretch(); mainLayout->addWidget(m_topRec); mainLayout->addWidget(m_bottomRec); mainLayout->addStretch(); this->setLayout(mainLayout); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dseparatorhorizontal.h000066400000000000000000000021651325435343100225410ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSEPARATORHORIZONTAL_H #define DSEPARATORHORIZONTAL_H #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DSeparatorHorizontal : public QWidget { Q_OBJECT public: explicit DSeparatorHorizontal(QWidget *parent = 0); private: QWidget *m_topRec = NULL; QWidget *m_bottomRec = NULL; }; DWIDGET_END_NAMESPACE #endif // DSEPARATORHORIZONTAL_H dtkwidget-2.0.7.2/src/widgets/dseparatorvertical.cpp000066400000000000000000000034141325435343100225120ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dseparatorvertical.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DSeparatorVertical * \brief The DSeparatorVertical class provides an vertical separator. * * DSeparatorVertical has fixed two pixels in width. */ /*! * \brief DSeparatorVertical::DSeparatorVertical constructs an instance of DSeparatorVertical. * \param parent is passed to QWidget constructor. */ DSeparatorVertical::DSeparatorVertical(QWidget *parent) : QWidget(parent) { DThemeManager::registerWidget(this); this->setFixedWidth(2); this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); m_leftRec = new QWidget(this); m_leftRec->setObjectName("DSeparatorLeftRec"); m_rightRec = new QWidget(this); m_rightRec->setObjectName("DSeparatorRightRec"); QHBoxLayout *mainLayout = new QHBoxLayout(this); mainLayout->setMargin(0); mainLayout->setSpacing(0); mainLayout->addStretch(); mainLayout->addWidget(m_leftRec); mainLayout->addWidget(m_rightRec); mainLayout->addStretch(); this->setLayout(mainLayout); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dseparatorvertical.h000066400000000000000000000021531325435343100221560ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSEPARATORVERTICAL_H #define DSEPARATORVERTICAL_H #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DSeparatorVertical : public QWidget { Q_OBJECT public: explicit DSeparatorVertical(QWidget *parent = 0); private: QWidget *m_leftRec = NULL; QWidget *m_rightRec = NULL; }; DWIDGET_END_NAMESPACE #endif // DSEPARATORVERTICAL_H dtkwidget-2.0.7.2/src/widgets/dsettingsdialog.cpp000066400000000000000000000060251325435343100220010ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dsettingsdialog.h" #include #include #include #include #include "dsettingswidgetfactory.h" #include "private/settings/content.h" #include "private/settings/navigation.h" #include "dthememanager.h" #include "dwindowclosebutton.h" #include "dspinbox.h" #include "dbuttonlist.h" #include "doptionlist.h" DWIDGET_BEGIN_NAMESPACE class DSettingsDialogPrivate { public: DSettingsDialogPrivate(DSettingsDialog *parent) : q_ptr(parent) {} Navigation *leftFrame; QFrame *rightFrame; QVBoxLayout *rightLayout; Content *content; DSettingsDialog *q_ptr; Q_DECLARE_PUBLIC(DSettingsDialog) }; DSettingsDialog::DSettingsDialog(QWidget *parent) : DAbstractDialog(parent), d_ptr(new DSettingsDialogPrivate(this)) { Q_D(DSettingsDialog); DThemeManager::registerWidget(this); setObjectName("DSettingsDialog"); auto layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); d->leftFrame = new Navigation; d->leftFrame->layout()->setContentsMargins(0, 30, 0, 0); layout->addWidget(d->leftFrame); d->rightFrame = new QFrame; d->rightFrame->setObjectName("RightFrame"); d->rightLayout = new QVBoxLayout(d->rightFrame); d->rightLayout->setContentsMargins(1, 5, 5, 0); d->rightLayout->setSpacing(0); d->content = new Content; auto closeBt = new DImageButton; closeBt->setObjectName("DSettingsDialogClose"); d->rightLayout->addWidget(closeBt, 0, Qt::AlignVCenter | Qt::AlignRight); d->rightLayout->addWidget(d->content); layout->addWidget(d->rightFrame); setFixedWidth(680); connect(d->leftFrame, &Navigation::selectedGroup, d->content, &Content::onScrollToGroup); connect(d->content, &Content::scrollToGroup, d->leftFrame, &Navigation::onSelectGroup); connect(closeBt, &DWindowCloseButton::clicked, this, &DSettingsDialog::close); } DSettingsDialog::~DSettingsDialog() { } DSettingsWidgetFactory *DSettingsDialog::widgetFactory() const { Q_D(const DSettingsDialog); return d->content->widgetFactory(); } void DSettingsDialog::updateSettings(Dtk::Core::DSettings *settings) { Q_D(DSettingsDialog); d->leftFrame->updateSettings(settings); d->content->updateSettings(settings); adjustSize(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dsettingsdialog.h000066400000000000000000000024751325435343100214530ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include #include "dabstractdialog.h" DWIDGET_BEGIN_NAMESPACE class DSettingsWidgetFactory; class DSettingsDialogPrivate; class LIBDTKWIDGETSHARED_EXPORT DSettingsDialog : public DAbstractDialog { Q_OBJECT public: DSettingsDialog(QWidget *parent = 0); ~DSettingsDialog(); DSettingsWidgetFactory* widgetFactory() const; public Q_SLOTS: void updateSettings(DTK_CORE_NAMESPACE::DSettings *settings); private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), DSettingsDialog) }; DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dsettingswidgetfactory.cpp000066400000000000000000000406411325435343100234170ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dsettingswidgetfactory.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "private/settings/shortcutedit.h" #include "private/settings/buttongroup.h" #include "private/settings/combobox.h" DWIDGET_BEGIN_NAMESPACE QWidget *DSettingsWidgetFactory::createTwoColumWidget(DTK_CORE_NAMESPACE::DSettingsOption *option, QWidget *rightWidget) { auto optionFrame = new QFrame; optionFrame->setMinimumHeight(30); optionFrame->setObjectName("OptionFrame"); // optionFrame->setStyleSheet("QFrame{border: 1px solid red;}"); auto optionLayout = new QGridLayout(optionFrame); optionLayout->setContentsMargins(0, 0, 0, 0); optionLayout->setSpacing(0); rightWidget->setMinimumWidth(240); rightWidget->setStyleSheet("QWidget{font-size: 12px;}"); if (!option->name().isEmpty()) { optionLayout->setColumnMinimumWidth(0, 110); optionLayout->setHorizontalSpacing(20); optionLayout->setColumnStretch(0, 10); optionLayout->setColumnStretch(1, 100); auto trName = QObject::tr(option->name().toStdString().c_str()); auto labelWidget = new QLabel(trName); labelWidget->setContentsMargins(5, 0, 0, 0); labelWidget->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); labelWidget->setMinimumWidth(150); labelWidget->setFixedWidth(160); labelWidget->setObjectName("OptionLabel"); labelWidget->setStyleSheet("#OptionLabel{font-size: 12px; }"); optionLayout->addWidget(labelWidget, 0, 0, Qt::AlignLeft | Qt::AlignVCenter); optionLayout->addWidget(rightWidget, 0, 1, Qt::AlignLeft | Qt::AlignVCenter); } else { optionLayout->setColumnMinimumWidth(0, 5); optionLayout->addWidget(rightWidget, 0, 1, Qt::AlignLeft | Qt::AlignVCenter); } return optionFrame; } QWidget *createShortcutEditOptionHandle(QObject *opt) { auto option = qobject_cast(opt); auto rightWidget = new ShortcutEdit(); rightWidget->setObjectName("OptionShortcutEdit"); auto updateWidgetValue = [rightWidget](const QVariant & optionValue) { switch (optionValue.type()) { case QVariant::List: case QVariant::StringList: { QStringList keyseqs = optionValue.toStringList(); if (keyseqs.length() == 2) { auto modifier = static_cast(keyseqs.value(0).toInt()); auto key = static_cast(keyseqs.value(1).toInt()); rightWidget->setShortCut(modifier, key); } break; } case QVariant::String: { rightWidget->setShortCut(optionValue.toString()); break; } default: qCritical() << "unknown variant type" << optionValue; } }; auto optionValue = option->value(); updateWidgetValue(optionValue); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, rightWidget); // keep raw value type switch (optionValue.type()) { case QVariant::List: case QVariant::StringList: { option->connect(rightWidget, &ShortcutEdit::shortcutChanged, option, [ = ](Qt::KeyboardModifiers modifier, Qt::Key key) { QStringList keyseqs; keyseqs << QString("%1").arg(modifier) << QString("%1").arg(key); option->setValue(keyseqs); }); break; } case QVariant::String: { option->connect(rightWidget, &ShortcutEdit::shortcutStringChanged, option, [ = ](const QString & seqString) { option->setValue(seqString); }); break; } default: qCritical() << "unknown variant type" << optionValue; } option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { updateWidgetValue(value); rightWidget->update(); }); return optionWidget; } QWidget *createCheckboxOptionHandle(QObject *opt) { auto option = qobject_cast(opt); auto value = option->data("text").toString(); auto trName = QObject::tr(value.toStdString().c_str()); auto checkboxFrame = new QWidget; auto checkboxLayout = new QHBoxLayout(checkboxFrame); checkboxLayout->setSpacing(0); checkboxLayout->setContentsMargins(0, 0, 0, 0); auto rightWidget = new QCheckBox(""); auto checkboxLabel = new QLabel(trName); checkboxLabel->setWordWrap(true); checkboxLabel->setMinimumWidth(320); checkboxLayout->addWidget(rightWidget); checkboxLayout->addSpacing(5); checkboxLayout->addWidget(checkboxLabel); checkboxLayout->addStretch(); rightWidget->setObjectName("OptionCheckbox"); rightWidget->setChecked(option->value().toBool()); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, checkboxFrame); option->connect(rightWidget, &QCheckBox::stateChanged, option, [ = ](int status) { option->setValue(status == Qt::Checked); }); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { rightWidget->setChecked(value.toBool()); rightWidget->update(); }); return optionWidget; } QWidget *createLineEditOptionHandle(QObject *opt) { auto option = qobject_cast(opt); auto value = option->data("text").toString(); auto trName = QObject::tr(value.toStdString().c_str()); auto rightWidget = new QLineEdit(trName); rightWidget->setFixedHeight(24); rightWidget->setObjectName("OptionLineEdit"); rightWidget->setText(option->value().toString()); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, rightWidget); option->connect(rightWidget, &QLineEdit::editingFinished, option, [ = ]() { option->setValue(rightWidget->text()); }); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { rightWidget->setText(value.toString()); rightWidget->update(); }); return optionWidget; } QWidget *createComboBoxOptionHandle(QObject *opt) { auto option = qobject_cast(opt); auto rightWidget = new ComboBox(); rightWidget->setFocusPolicy(Qt::StrongFocus); rightWidget->setFixedHeight(24); rightWidget->setObjectName("OptionLineEdit"); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, rightWidget); auto initComboxList = [ = ](const QStringList & data) { for (auto item : data) { auto trName = QObject::tr(item.toStdString().c_str()); rightWidget->addItem(trName); } auto current = option->value().toInt(); rightWidget->setCurrentIndex(current); option->connect(rightWidget, static_cast(&QComboBox::currentIndexChanged), option, [ = ](int index) { option->setValue(index); }); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { rightWidget->setCurrentIndex(value.toInt()); }); }; auto initComboxMap = [ = ](const QMap &data) { auto keys = data.value("keys").toStringList(); auto values = data.value("values").toStringList(); for (int i = 0; i < keys.length(); ++i) { auto trName = QObject::tr(values.value(i).toStdString().c_str()); rightWidget->addItem(trName, keys.value(i)); } auto currentData = option->value().toString(); auto currentIndex = rightWidget->findData(currentData); rightWidget->setCurrentIndex(currentIndex); option->connect(rightWidget, static_cast(&QComboBox::currentIndexChanged), option, [ = ](int index) { option->setValue(keys.value(index)); }); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { auto currentIndex = rightWidget->findData(value.toString()); rightWidget->setCurrentIndex(currentIndex); }); }; auto updateData = [ = ](const QString & dataType, const QVariant & data) { if ("items" != dataType) { return; } rightWidget->clear(); if (data.type() == QVariant::StringList) { initComboxList(data.toStringList()); } if (data.type() == QVariant::Map) { initComboxMap(data.toMap()); } rightWidget->update(); }; auto initData = option->data("items"); updateData("items", initData); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::dataChanged, rightWidget, [ = ](const QString & dataType, const QVariant & value) { updateData(dataType, value); }); return optionWidget; } QWidget *createButtonGroupOptionHandle(QObject *opt) { auto option = qobject_cast(opt); auto rightWidget = new ButtonGroup(); rightWidget->setFixedHeight(24); rightWidget->setObjectName("OptionButtonGroup"); auto items = option->data("items").toStringList(); rightWidget->setButtons(items); rightWidget->setCheckedButton(0); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, rightWidget); rightWidget->setParent(optionWidget); option->connect(rightWidget, &ButtonGroup::buttonChecked, option, [ = ](int id) { option->setValue(id); }); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { rightWidget->setCheckedButton(value.toInt()); rightWidget->update(); }); return optionWidget; } QWidget *createRadioGroupOptionHandle(QObject *opt) { auto option = qobject_cast(opt); auto items = option->data("items").toStringList(); auto rightWidget = new QGroupBox; rightWidget->setContentsMargins(0, 0, 0, 0); rightWidget->setObjectName("OptionRadioGroup"); rightWidget->setAlignment(Qt::AlignLeft); rightWidget->setFixedHeight(24 * items.length() + 8); auto rgLayout = new QVBoxLayout; rgLayout->setContentsMargins(0, 0, 0, 0); auto index = 0; QList buttonList; for (auto item : items) { auto rb = new QRadioButton(QObject::tr(item.toStdString().c_str())); rb->setFixedHeight(24); rb->setProperty("_dtk_widget_settings_radiogroup_index", index); rgLayout->addWidget(rb); ++index; option->connect(rb, &QRadioButton::clicked, option, [ = ](int) { auto index = rb->property("_dtk_widget_settings_radiogroup_index").toInt(); option->setValue(index); }); buttonList << rb; } rightWidget->setLayout(rgLayout); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, rightWidget); rightWidget->setParent(optionWidget); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ buttonList ](const QVariant & value) { auto index = value.toInt(); if (buttonList.length() > index) { buttonList.value(index)->setChecked(true); } }); index = option->value().toInt(); if (buttonList.length() > index) { buttonList.value(index)->setChecked(true); } rightWidget->setStyleSheet("QGroupBox{border: none;} QRadioButton{font-size:12px;}"); return optionWidget; } QWidget *createSpinButtonOptionHandle(QObject *opt) { auto option = qobject_cast(opt); auto rightWidget = new QSpinBox(); rightWidget->setFixedHeight(24); rightWidget->setObjectName("OptionDSpinBox"); rightWidget->setValue(option->value().toInt()); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, rightWidget); option->connect(rightWidget, static_cast(&QSpinBox::valueChanged), option, [ = ](int value) { option->setValue(value); }); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { rightWidget->setValue(value.toInt()); rightWidget->update(); }); return optionWidget; } QWidget *createSliderOptionHandle(QObject *opt) { auto option = qobject_cast(opt); auto rightWidget = new QSlider(); rightWidget->setFixedHeight(24); rightWidget->setObjectName("OptionQSlider"); rightWidget->setOrientation(Qt::Horizontal); rightWidget->setMaximum(option->data("max").toInt()); rightWidget->setMinimum(option->data("min").toInt()); rightWidget->setValue(option->value().toInt()); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, rightWidget); option->connect(rightWidget, &QSlider::valueChanged, option, [ = ](int value) { rightWidget->blockSignals(true); option->setValue(value); rightWidget->blockSignals(false); }); option->connect(option, &DTK_CORE_NAMESPACE::DSettingsOption::valueChanged, rightWidget, [ = ](const QVariant & value) { rightWidget->setValue(value.toInt()); rightWidget->update(); }); return optionWidget; } QWidget *createUnsupportHandle(QObject *opt) { auto option = qobject_cast(opt); auto rightWidget = new QLabel(); rightWidget->setFixedHeight(24); rightWidget->setObjectName("OptionUnsupport"); rightWidget->setText("Unsupport option type: " + option->viewType()); auto optionWidget = DSettingsWidgetFactory::createTwoColumWidget(option, rightWidget); // optionWidget->setStyleSheet("QFrame{border: 1px solid red;}"); return optionWidget; } class DSettingsWidgetFactoryPrivate { public: DSettingsWidgetFactoryPrivate(DSettingsWidgetFactory *parent) : q_ptr(parent) { widgetCreateHandles.insert("checkbox", createCheckboxOptionHandle); widgetCreateHandles.insert("lineedit", createLineEditOptionHandle); widgetCreateHandles.insert("combobox", createComboBoxOptionHandle); widgetCreateHandles.insert("shortcut", createShortcutEditOptionHandle); widgetCreateHandles.insert("spinbutton", createSpinButtonOptionHandle); widgetCreateHandles.insert("buttongroup", createButtonGroupOptionHandle); widgetCreateHandles.insert("radiogroup", createRadioGroupOptionHandle); widgetCreateHandles.insert("slider", createSliderOptionHandle); } QMap > widgetCreateHandles; DSettingsWidgetFactory *q_ptr; Q_DECLARE_PUBLIC(DSettingsWidgetFactory) }; DSettingsWidgetFactory::DSettingsWidgetFactory(QObject *parent) : QObject(parent), d_ptr(new DSettingsWidgetFactoryPrivate(this)) { } DSettingsWidgetFactory::~DSettingsWidgetFactory() { } void DSettingsWidgetFactory::registerWidget(const QString &viewType, std::function handler) { Q_D(DSettingsWidgetFactory); d->widgetCreateHandles.insert(viewType, handler); } QWidget *DSettingsWidgetFactory::createWidget(QPointer option) { Q_D(DSettingsWidgetFactory); auto handle = d->widgetCreateHandles.value(option->viewType()); if (handle) { return handle(option.data()); } else { return createUnsupportHandle(option.data()); } } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dsettingswidgetfactory.h000066400000000000000000000031371325435343100230630ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include #include "dtkwidget_global.h" DCORE_BEGIN_NAMESPACE class DSettingsOption; DCORE_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DSettingsWidgetFactoryPrivate; class LIBDTKWIDGETSHARED_EXPORT DSettingsWidgetFactory : public QObject { Q_OBJECT public: typedef QWidget *(WidgetCreateHandler)(QObject *); explicit DSettingsWidgetFactory(QObject *parent = 0); ~DSettingsWidgetFactory(); void registerWidget(const QString &viewType, std::function handler); QWidget *createWidget(QPointer settings); static QWidget *createTwoColumWidget(DTK_CORE_NAMESPACE::DSettingsOption *option, QWidget *rightWidget); private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), DSettingsWidgetFactory) }; DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dshortcutedit.cpp000066400000000000000000000175211325435343100215050ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dshortcutedit.h" #include "dthememanager.h" #include #include #include #include #include DWIDGET_USE_NAMESPACE // static const varibles const QString DShortcutEdit::DefaultTips = tr("Please input a new shortcut"); DShortcutEdit::DShortcutEdit(QWidget *parent) : QFrame(parent) { DThemeManager::registerWidget(this); m_keysEdit = new QLabel(DefaultTips); m_keysEdit->setObjectName("Edit"); m_keysEdit->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); m_keysEdit->installEventFilter(this); m_keysEdit->setFocusPolicy(Qt::StrongFocus); m_keysEdit->hide(); m_keysLabel = new DShortcutEditLabel; m_keysLabel->setObjectName("Label"); m_keysLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight); m_keysLabel->installEventFilter(this); m_keysLabel->setFocusPolicy(Qt::NoFocus); QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(m_keysEdit); layout->addWidget(m_keysLabel); layout->setSpacing(0); layout->setMargin(0); setLayout(layout); setFocusPolicy(Qt::NoFocus); // Meta+Ctrl+Alt+Shift+Backspace is longest shortcut keys setMinimumWidth(180); #ifdef QT_DEBUG // for test setShortcutKey("Meta+Ctrl+Alt+Shift+Backspace"); #endif m_keyMapping.insert("PgDown", "PageDown"); m_keyMapping.insert("PgUp", "PageUp"); m_blockedShortcutKeys.append(QRegExp("^Backspace$")); //connect(this, &DShortcutEdit::invalidShortcutKey, [this] () -> void {m_keysLabel->setEchoState(DShortcutEditLabel::Invalid);}); } bool DShortcutEdit::eventFilter(QObject *o, QEvent *e) { if (o == m_keysEdit && e->type() == QEvent::FocusOut && m_keysEdit->isVisible()) toEchoMode(); else if (o == m_keysLabel && e->type() == QEvent::MouseButtonRelease && m_keysLabel->isVisible()) toInputMode(); else if (o == m_keysEdit && e->type() == QEvent::KeyPress) shortcutKeyPress(static_cast(e)); return false; } void DShortcutEdit::clearShortcutKey() { setShortcutKey(QString()); } QSize DShortcutEdit::sizeHint() const { if (!m_keysLabel || !m_keysEdit) return QSize(); return QSize(qMax(m_keysLabel->sizeHint().width(), m_keysEdit->sizeHint().width()), qMax(m_keysLabel->sizeHint().height(), m_keysEdit->sizeHint().height())); } void DShortcutEdit::setShortcutKey(const QString &key) { if (key.isEmpty()) m_keysLabel->setText(tr("None")); else m_keysLabel->setText(convertShortcutKeys(key)); m_keysEdit->setText(convertShortcutKeys(key)); m_shortcutKeys = key; Q_EMIT shortcutKeysChanged(m_shortcutKeys); } void DShortcutEdit::setKeyMapping(const QMap &mapping) { m_keyMapping = mapping; } void DShortcutEdit::setBlockShortcutKeysList(const QList &kList) { m_blockedShortcutKeys = kList; } void DShortcutEdit::setInValidState() const { m_keysLabel->setEchoState(DShortcutEditLabel::Invalid); } void DShortcutEdit::setNormalState() const { m_keysLabel->setEchoState(DShortcutEditLabel::Normal); } const QMap &DShortcutEdit::getKeyMapping() const { return std::move(m_keyMapping); } const QList &DShortcutEdit::getBlockShortcutKeysList() const { return m_blockedShortcutKeys; } bool DShortcutEdit::isValidShortcutKey(const QString &key) { for (const QRegExp & k : m_blockedShortcutKeys) if (key.contains(k)) return false; /*const QStringList keys = key.split("+"); if (keys.size() == 1) { const QString firstKey = keys.first(); // F1 ~ F12 if (!firstKey.contains(QRegExp("^F(\\d|1[0-2])$"))) return false; } const QString lastKey = keys.last(); if (lastKey.size() == 2 && !lastKey.at(0).isLetter()) return false; if (lastKey == "Meta" || lastKey == "Ctrl" || lastKey == "Shift" || lastKey == "Alt") return false;*/ qWarning() << "isValidShortcutKey: " << key; return true; } void DShortcutEdit::toEchoMode() { m_keysLabel->show(); m_keysEdit->hide(); Q_EMIT shortcutKeysFinished(m_shortcutKeys); if (!m_shortcutKeys.isEmpty() && !isValidShortcutKey(m_shortcutKeys)) Q_EMIT invalidShortcutKey(m_shortcutKeys); } void DShortcutEdit::toInputMode() const { m_keysLabel->hide(); m_keysLabel->setEchoState(DShortcutEditLabel::Normal); m_keysEdit->show(); m_keysEdit->setFocus(); m_keysEdit->setText(DefaultTips); } void DShortcutEdit::shortcutKeyPress(QKeyEvent *e) { //qDebug() << e->key() << e->text() << e->count() << Qt::CTRL << e->nativeScanCode() << e->nativeVirtualKey(); m_shortcutKeys.clear(); int state = 0; if ((e->modifiers() & Qt::ShiftModifier) && (e->text().isEmpty() || !e->text().at(0).isPrint() || e->text().at(0).isLetterOrNumber() || e->text().at(0).isSpace())) state |= Qt::SHIFT; if (e->modifiers() & Qt::ControlModifier) state |= Qt::CTRL; if (e->modifiers() & Qt::MetaModifier) state |= Qt::META; if (e->modifiers() & Qt::AltModifier) state |= Qt::ALT; int key = e->key() | state; qDebug() << "keys: " << QKeySequence(key, 0, 0, 0).toString(QKeySequence::NativeText); m_shortcutKeys = QKeySequence(key, 0, 0, 0).toString(QKeySequence::NativeText); //qDebug() << m_shortcutKeys << e->text() << e->key(); //qDebug() << "keys: " << int(e->key() & ~(Qt::SHIFT | Qt::ControlModifier | Qt::META | Qt::ALT)); // if pressed key is "Backspace", its means "clear all" if (m_shortcutKeys == "Backspace") return clearShortcutKey(); setShortcutKey(m_shortcutKeys); QString lastKey = m_shortcutKeys.split("+").last(); qDebug() << "last: " << lastKey << lastKey.size(); // if lastKey is not alt, shift, ctrl, meta, shortcut key is finished. if (lastKey.size() == 2 && !lastKey.at(0).isLetter()) return; if (lastKey != "Meta" && lastKey != "Ctrl" && lastKey != "Shift" && lastKey != "Alt") toEchoMode(); } QString DShortcutEdit::convertShortcutKeys(const QString &keys) { QString newKeys = keys; for (const QString & k : m_keyMapping.keys()) newKeys.replace(k, m_keyMapping[k]); return newKeys; } DShortcutEditLabel::DShortcutEditLabel(QWidget *parent) : QLabel(parent) { setEchoState(Normal); connect(this, &DShortcutEditLabel::colorSettingChange, [this] () -> void {setEchoState(m_state);}); } void DShortcutEditLabel::setEchoState(const DShortcutEditLabel::EchoState state) { QColor c = m_colorNormal; switch (state) { case Normal: c = m_colorNormal; break; case Hover: c = m_colorHover; break; case Invalid: c = m_colorInvalid; break; default: c = m_colorNormal; break; } setStyleSheet(QString("color:%1;").arg(c.name())); update(); m_state = state; } void DShortcutEditLabel::enterEvent(QEvent *) { if (m_state == Normal) setEchoState(Hover); } void DShortcutEditLabel::leaveEvent(QEvent *) { if (m_state == Hover) setEchoState(Normal); } dtkwidget-2.0.7.2/src/widgets/dshortcutedit.h000066400000000000000000000057271325435343100211570ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSHORTCUTEDIT_H #define DSHORTCUTEDIT_H #include #include #include #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DShortcutEditLabel; class LIBDTKWIDGETSHARED_EXPORT DShortcutEdit : public QFrame { Q_OBJECT public: DShortcutEdit(QWidget *parent = 0); QSize sizeHint() const; bool eventFilter(QObject *o, QEvent *e); bool isValidShortcutKey(const QString & key); const QMap &getKeyMapping() const; const QList &getBlockShortcutKeysList() const; Q_SIGNALS: void shortcutKeysChanged(const QString & shortcutKeys); void shortcutKeysFinished(const QString & shortcutKeys); void invalidShortcutKey(const QString & shortcutKeys); public Q_SLOTS: void clearShortcutKey(); void setShortcutKey(const QString & key); void setKeyMapping(const QMap & mapping); void setBlockShortcutKeysList(const QList & kList); void setInValidState() const; void setNormalState() const; private Q_SLOTS: void toEchoMode(); void toInputMode() const; void shortcutKeyPress(QKeyEvent *e); private: QString convertShortcutKeys(const QString & keys); private: DShortcutEditLabel *m_keysLabel; QLabel *m_keysEdit; QString m_shortcutKeys; QList m_blockedShortcutKeys; QMap m_keyMapping; static const QString DefaultTips; }; class DShortcutEditLabel : public QLabel { Q_OBJECT Q_PROPERTY(QColor echoNormal MEMBER m_colorNormal NOTIFY colorSettingChange DESIGNABLE true SCRIPTABLE true) Q_PROPERTY(QColor echoHover MEMBER m_colorHover NOTIFY colorSettingChange DESIGNABLE true SCRIPTABLE true) Q_PROPERTY(QColor echoInvalid MEMBER m_colorInvalid NOTIFY colorSettingChange DESIGNABLE true SCRIPTABLE true) public: enum EchoState {Normal = 1, Hover, Invalid}; public: DShortcutEditLabel(QWidget * parent = 0); void setEchoState(const EchoState state); Q_SIGNALS: void colorSettingChange(); private: void enterEvent(QEvent *); void leaveEvent(QEvent *); private: QColor m_colorNormal; QColor m_colorHover; QColor m_colorInvalid; EchoState m_state = Normal; }; DWIDGET_END_NAMESPACE #endif // DSHORTCUTEDIT_H dtkwidget-2.0.7.2/src/widgets/dsimplecombobox.cpp000066400000000000000000000062401325435343100220020ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dsimplecombobox.h" #include "private/dcombobox_p.h" DWIDGET_BEGIN_NAMESPACE class SimpleDelegateItem : public DComboBoxItem { Q_OBJECT public: explicit SimpleDelegateItem(QWidget *parent = 0); }; class DComboBoxSimpleDelegate : public DAbstractComboBoxDelegate { public: explicit DComboBoxSimpleDelegate(QObject *parent = 0); QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setEditorData(QWidget *editor, const QModelIndex &index) const; }; SimpleDelegateItem::SimpleDelegateItem(QWidget *parent) : DComboBoxItem(parent) { } DComboBoxSimpleDelegate::DComboBoxSimpleDelegate(QObject *parent) : DAbstractComboBoxDelegate(parent) { } QWidget * DComboBoxSimpleDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(option) Q_UNUSED(index) SimpleDelegateItem * editor = new SimpleDelegateItem(parent); editor->setFixedHeight(MENU_ITEM_HEIGHT); return editor; } void DComboBoxSimpleDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QJsonObject dataObj = index.model()->data(index, Qt::DisplayRole).toJsonValue().toObject(); if (dataObj.isEmpty()) return; SimpleDelegateItem *simpleItem = static_cast(editor); QString title = ""; if (simpleItem && dataObj.contains("itemText")) title = dataObj.value("itemText").toString(); simpleItem->setText(title); } DSimpleComboBox::DSimpleComboBox(QWidget *parent) : DComboBox(parent) { DComboBoxSimpleDelegate *dbfb = new DComboBoxSimpleDelegate(this); setItemDelegate(dbfb); setModel(new DComboBoxModel(this)); connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChange(int))); } void DSimpleComboBox::addItem(const QString &text) { QJsonObject nameObj; nameObj.insert("itemText", QJsonValue(text)); dcomboBoxModel()->append(nameObj); // Make the combo boxes always displayed. view()->openPersistentEditor(dcomboBoxModel()->getModelIndex(dcomboBoxModel()->count() - 1)); } void DSimpleComboBox::addItems(const QStringList &texts) { Q_FOREACH (QString text, texts) { this->addItem(text); } } void DSimpleComboBox::onCurrentIndexChange(int index) { QJsonObject nameObj = dcomboBoxModel()->getJsonData(index); Q_EMIT currentTextChanged(nameObj["itemText"].toString()); } DWIDGET_END_NAMESPACE #include "dsimplecombobox.moc" dtkwidget-2.0.7.2/src/widgets/dsimplecombobox.h000066400000000000000000000025231325435343100214470ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSIMPLECOMBOBOX_H #define DSIMPLECOMBOBOX_H #include #include "dtkwidget_global.h" #include "dcomboboxmodel.h" #include "dabstractcomboboxdelegate.h" #include "dcombobox.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT D_DECL_DEPRECATED_X("Use QCombobBox directly.") DSimpleComboBox : public DComboBox { Q_OBJECT public: explicit DSimpleComboBox(QWidget *parent = 0); void addItem(const QString &text); void addItems(const QStringList &texts); Q_SIGNALS: void currentTextChanged(const QString &); private: Q_SLOT void onCurrentIndexChange(int index); }; DWIDGET_END_NAMESPACE #endif // DSIMPLECOMBOBOX_H dtkwidget-2.0.7.2/src/widgets/dsimplelistitem.cpp000066400000000000000000000020001325435343100220120ustar00rootroot00000000000000/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- * -*- coding: utf-8 -*- * * Copyright (C) 2011 ~ 2017 Deepin, Inc. * 2011 ~ 2017 Wang Yong * * Author: Wang Yong * Maintainer: Wang Yong * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dsimplelistitem.h" DWIDGET_BEGIN_NAMESPACE DSimpleListItem::DSimpleListItem() { } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dsimplelistitem.h000066400000000000000000000062501325435343100214720ustar00rootroot00000000000000/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- * -*- coding: utf-8 -*- * * Copyright (C) 2011 ~ 2017 Deepin, Inc. * 2011 ~ 2017 Wang Yong * * Author: Wang Yong * Maintainer: Wang Yong * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSIMPLELISTITEM_H #define DSIMPLELISTITEM_H #include #include #include DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DSimpleListItem : public QObject { Q_OBJECT public: DSimpleListItem(); /* * The interface function that used to compare the two DSimpleListItem * The DSimpleListView requires this interface to keep the selected items unchanged when refreshed * * @item any subclass of DSimpleListItem, you can use static_cast in implementation to access any attribute to compare two items * @return return true if two items have same attribute, the compare method implement by subclass of DSimpleListItem */ virtual bool sameAs(DSimpleListItem *item)=0; /* * The interface function that used to draw background of DSimpleListItem. * Such as background and selected effect. * * @rect row corresponding to the drawing of the rectangular area * @painter the painter used to draw anything you want * @index the index of DSimpleListItem, you can draw different rows effect based on the index, such as the zebra crossing * @isSelect current item is selected, you can draw selected effect under content when isSelect is true * @isHover current item is hovered, you can draw hover effect under content when isHover is true */ virtual void drawBackground(QRect rect, QPainter *painter, int index, bool isSelect, bool isHover)=0; /* * The interface function that used to draw foreground of DSimpleListItem. * * @rect column corresponding to the drawing of the rectangular area * @painter the painter used to draw anything you want * @column the column of DSimpleListItem, you can draw different column content based on the column index * @index the index of DSimpleListItem, you can draw different rows effect based on the index, such as the zebra crossing * @isSelect current item is selected, you can draw selected effect under content when isSelect is true * @isHover current item is hovered, you can draw hover effect under content when isHover is true */ virtual void drawForeground(QRect rect, QPainter *painter, int column, int index, bool isSelect, bool isHover)=0; }; DWIDGET_END_NAMESPACE #endif dtkwidget-2.0.7.2/src/widgets/dsimplelistview.cpp000066400000000000000000001443741325435343100220530ustar00rootroot00000000000000/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- * -*- coding: utf-8 -*- * * Copyright (C) 2011 ~ 2017 Deepin, Inc. * 2011 ~ 2017 Wang Yong * * Author: Wang Yong * Maintainer: Wang Yong * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dsimplelistview.h" #include #include #include #include #include #include #include #include #include "dhidpihelper.h" DCORE_USE_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DSimpleListViewPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DSimpleListViewPrivate(DSimpleListView *parent) : DObjectPrivate(parent) { } QList getSearchItems(QList items); int getItemsTotalHeight(); int getTopRenderOffset(); void sortItemsByColumn(int column, bool descendingSort); DSimpleListItem *lastHoverItem; DSimpleListItem *lastSelectItem; DSimpleListItem *drawHoverItem; DSimpleListItem *mouseHoverItem; QList *listItems; QList *renderItems; QList *selectionItems; QList columnTitles; QList *sortingAlgorithms; QList *sortingOrderes; QList columnWidths; QString searchContent; QTimer *hideScrollbarTimer; SearchAlgorithm searchAlgorithm; bool defaultSortingOrder; bool mouseAtScrollArea; bool mouseDragScrollbar; bool drawFrame; int alwaysVisibleColumn; int clipRadius; int defaultSortingColumn; int hideScrollbarDuration; int lastHoverColumnIndex; int oldRenderOffset; int renderOffset; int rowHeight; int scrollDistance; int scrollStartY; int scrollUnit; int scrollbarDefaultWidth; int scrollbarDragWidth; int scrollbarMinHeight; int scrollbarPadding; int titleArrowPadding; int titleHeight; int titleHoverColumn; int titlePadding; int titlePressColumn; D_DECLARE_PUBLIC(DSimpleListView) }; DSimpleListView::DSimpleListView(QWidget *parent) : QWidget(parent), DObject(*new DSimpleListViewPrivate(this)) { D_D(DSimpleListView); // Init. installEventFilter(this); // add event filter setMouseTracking(true); // make MouseMove can response d->scrollDistance = 0; d->renderOffset = 0; d->titleHeight = 0; d->titleArrowPadding = 4; d->titlePadding = 14; d->rowHeight = 36; d->searchContent = ""; d->searchAlgorithm = NULL; d->titleHoverColumn = -1; d->titlePressColumn = -1; arrowUpDarkNormalImage = DHiDPIHelper::loadNxPixmap(":/images/dark/images/arrow_up_normal.svg"); arrowUpDarkHoverImage = DHiDPIHelper::loadNxPixmap(":/images/dark/images/arrow_up_hover.svg"); arrowUpDarkPressImage = DHiDPIHelper::loadNxPixmap(":/images/dark/images/arrow_up_press.svg"); arrowDownDarkNormalImage = DHiDPIHelper::loadNxPixmap(":/images/dark/images/arrow_down_normal.svg"); arrowDownDarkHoverImage = DHiDPIHelper::loadNxPixmap(":/images/dark/images/arrow_down_hover.svg"); arrowDownDarkPressImage = DHiDPIHelper::loadNxPixmap(":/images/dark/images/arrow_down_press.svg"); arrowUpLightNormalImage = DHiDPIHelper::loadNxPixmap(":/images/light/images/arrow_up_normal.svg"); arrowUpLightHoverImage = DHiDPIHelper::loadNxPixmap(":/images/light/images/arrow_up_hover.svg"); arrowUpLightPressImage = DHiDPIHelper::loadNxPixmap(":/images/light/images/arrow_up_press.svg"); arrowDownLightNormalImage = DHiDPIHelper::loadNxPixmap(":/images/light/images/arrow_down_normal.svg"); arrowDownLightHoverImage = DHiDPIHelper::loadNxPixmap(":/images/light/images/arrow_down_hover.svg"); arrowDownLightPressImage = DHiDPIHelper::loadNxPixmap(":/images/light/images/arrow_down_press.svg"); arrowUpNormalImage = arrowUpLightNormalImage; arrowUpHoverImage = arrowUpLightHoverImage; arrowUpPressImage = arrowUpLightPressImage; arrowDownNormalImage = arrowDownLightNormalImage; arrowDownHoverImage = arrowDownLightHoverImage; arrowDownPressImage = arrowDownLightPressImage; d->listItems = new QList(); d->renderItems = new QList(); d->selectionItems = new QList(); d->lastSelectItem = NULL; d->lastHoverItem = NULL; d->lastHoverColumnIndex = -1; d->drawHoverItem = NULL; d->mouseHoverItem = NULL; d->mouseAtScrollArea = false; d->mouseDragScrollbar = false; d->drawFrame = false; d->scrollbarDefaultWidth = 4; d->scrollbarDragWidth = 8; d->scrollbarMinHeight = 30; d->scrollbarPadding = 4; d->hideScrollbarDuration = 2000; d->oldRenderOffset = 0; d->clipRadius = 0; d->hideScrollbarTimer = NULL; d->sortingAlgorithms = new QList(); d->sortingOrderes = new QList(); } DSimpleListView::~DSimpleListView() { D_D(DSimpleListView); delete d->lastHoverItem; delete d->lastSelectItem; delete d->drawHoverItem; delete d->mouseHoverItem; delete d->listItems; delete d->renderItems; delete d->selectionItems; delete d->sortingAlgorithms; delete d->sortingOrderes; delete d->hideScrollbarTimer; } void DSimpleListView::setRowHeight(int height) { D_D(DSimpleListView); d->rowHeight = height; d->scrollUnit = d->rowHeight; } void DSimpleListView::setColumnTitleInfo(QList titles, QList widths, int height) { D_D(DSimpleListView); // Set column titles. d->columnTitles = titles; // Calcuate column title widths. d->columnWidths.clear(); QFont font; font.setPointSize(titleSize); QFontMetrics fm(font); for (int i = 0; i < widths.length(); i++) { if (widths[i] == -1) { d->columnWidths << widths[i]; } else { int renderTitleWidth = fm.width(titles[i]) + d->titlePadding + arrowUpNormalImage.width() / arrowUpNormalImage.devicePixelRatio() + d->titleArrowPadding * 2; d->columnWidths << std::max(widths[i], renderTitleWidth); } } // Set title height. d->titleHeight = height; } void DSimpleListView::setColumnHideFlags(QList toggleHideFlags, int visibleColumnIndex) { D_D(DSimpleListView); Q_ASSERT_X(toggleHideFlags.contains(false), "toggleHideFlags", "at least have one 'false' in list."); Q_ASSERT_X(toggleHideFlags.count() == d->columnTitles.count(), "toggleHideFlags", "hide flags length is not same as titles list."); d->alwaysVisibleColumn = visibleColumnIndex; columnVisibles.clear(); for (int i = 0; i < toggleHideFlags.count(); i++) { columnVisibles.append(toggleHideFlags[i]); } } void DSimpleListView::setColumnSortingAlgorithms(QList *algorithms, int sortColumn, bool descendingSort) { D_D(DSimpleListView); // Add sort algorithms. d->sortingAlgorithms = algorithms; for (int i = 0; i < d->sortingAlgorithms->count(); i++) { d->sortingOrderes->append(false); } // If sort column is -1, don't sort default. d->defaultSortingColumn = sortColumn; d->defaultSortingOrder = descendingSort; } void DSimpleListView::setSearchAlgorithm(SearchAlgorithm algorithm) { D_D(DSimpleListView); d->searchAlgorithm = algorithm; } void DSimpleListView::setClipRadius(int radius) { D_D(DSimpleListView); d->clipRadius = radius; } void DSimpleListView::setFrame(bool enableFrame, QColor color, double opacity) { D_D(DSimpleListView); d->drawFrame = enableFrame; frameColor = color; frameOpacity = opacity; } void DSimpleListView::addItems(QList items) { D_D(DSimpleListView); // Add item to list. d->listItems->append(items); QList searchItems = d->getSearchItems(items); d->renderItems->append(searchItems); // If user has click title to sort, sort items after add items to list. if (d->defaultSortingColumn != -1) { d->sortItemsByColumn(d->defaultSortingColumn, d->defaultSortingOrder); } // Repaint after add items. repaint(); } void DSimpleListView::removeItem(DSimpleListItem* item) { D_D(DSimpleListView); d->listItems->removeOne(item); d->renderItems->removeOne(item); if (d->renderOffset >= d->getItemsTotalHeight() - rect().height()) { d->renderOffset = adjustRenderOffset(d->renderOffset - d->rowHeight); } repaint(); } void DSimpleListView::clearItems() { D_D(DSimpleListView); // NOTE: // We need delete items in QList before clear QList to avoid *MEMORY LEAK* . qDeleteAll(d->listItems->begin(), d->listItems->end()); d->listItems->clear(); d->renderItems->clear(); } void DSimpleListView::addSelections(QList items, bool recordLastSelection) { D_D(DSimpleListView); // Add item to selection list. d->selectionItems->append(items); // Record last selection item to make selected operation continuously. if (recordLastSelection && d->selectionItems->count() > 0) { d->lastSelectItem = d->selectionItems->last(); } } void DSimpleListView::clearSelections(bool clearLastSelection) { D_D(DSimpleListView); // Clear selection list. d->selectionItems->clear(); if (clearLastSelection) { d->lastSelectItem = NULL; } } void DSimpleListView::refreshItems(QList items) { D_D(DSimpleListView); // Init. QList *newSelectionItems = new QList(); DSimpleListItem *newLastSelectionItem = NULL; DSimpleListItem *newLastHoverItem = NULL; // Save selection items and last selection item. for (DSimpleListItem *item:items) { for (DSimpleListItem *selectionItem:*d->selectionItems) { if (item->sameAs(selectionItem)) { newSelectionItems->append(item); break; } } } if (d->lastSelectItem != NULL) { for (DSimpleListItem *item:items) { if (item->sameAs(d->lastSelectItem)) { newLastSelectionItem = item; break; } } } if (d->lastHoverItem != NULL) { for (DSimpleListItem *item:items) { if (item->sameAs(d->lastHoverItem)) { newLastHoverItem = item; break; } } } d->lastHoverItem = NULL; // Update items. clearItems(); d->listItems->append(items); QList searchItems = d->getSearchItems(items); d->renderItems->append(searchItems); // Sort once if default sort column hasn't init. if (d->defaultSortingColumn != -1) { d->sortItemsByColumn(d->defaultSortingColumn, d->defaultSortingOrder); } // Restore selection items and last selection item. clearSelections(); addSelections(*newSelectionItems, false); d->lastSelectItem = newLastSelectionItem; d->lastHoverItem = newLastHoverItem; // Keep scroll position. d->renderOffset = adjustRenderOffset(d->renderOffset); // Render. repaint(); } void DSimpleListView::search(QString content) { D_D(DSimpleListView); if (content == "" && d->searchContent != content) { d->searchContent = content; d->renderItems->clear(); d->renderItems->append(*d->listItems); } else { d->searchContent = content; QList searchItems = d->getSearchItems(*d->listItems); d->renderItems->clear(); d->renderItems->append(searchItems); } repaint(); } void DSimpleListView::selectAllItems() { D_D(DSimpleListView); // Record old render offset to control scrollbar whether display. d->oldRenderOffset = d->renderOffset; // Select all items. clearSelections(); addSelections(*d->renderItems); // Scroll to top. d->renderOffset = d->getTopRenderOffset(); // Repaint. repaint(); } void DSimpleListView::selectFirstItem() { D_D(DSimpleListView); // Record old render offset to control scrollbar whether display. d->oldRenderOffset = d->renderOffset; // Select first item. clearSelections(); QList items = QList(); items << d->renderItems->first(); addSelections(items); // Scroll to top. d->renderOffset = d->getTopRenderOffset(); // Repaint. repaint(); } void DSimpleListView::selectLastItem() { D_D(DSimpleListView); // Record old render offset to control scrollbar whether display. d->oldRenderOffset = d->renderOffset; // Select last item. clearSelections(); QList items = QList(); items << d->renderItems->last(); addSelections(items); // Scroll to bottom. d->renderOffset = getBottomRenderOffset(); // Repaint. repaint(); } void DSimpleListView::selectPrevItem() { D_D(DSimpleListView); selectPrevItemWithOffset(1); } void DSimpleListView::selectNextItem() { D_D(DSimpleListView); selectNextItemWithOffset(1); } void DSimpleListView::shiftSelectPageDown() { D_D(DSimpleListView); shiftSelectNextItemWithOffset(getScrollAreaHeight() / d->rowHeight); } void DSimpleListView::shiftSelectPageUp() { D_D(DSimpleListView); shiftSelectPrevItemWithOffset(getScrollAreaHeight() / d->rowHeight); } void DSimpleListView::shiftSelectToEnd() { D_D(DSimpleListView); // Select last item if nothing selected yet. if (d->selectionItems->empty()) { selectLastItem(); } // Select items from last selected item to last item. else { // Found last selected index and do select operation. int lastSelectionIndex = d->renderItems->indexOf(d->lastSelectItem); shiftSelectItemsWithBound(lastSelectionIndex, d->renderItems->count() - 1); // Scroll to bottom. d->renderOffset = getBottomRenderOffset(); // Repaint. repaint(); } } void DSimpleListView::shiftSelectToHome() { D_D(DSimpleListView); // Select first item if nothing selected yet. if (d->selectionItems->empty()) { selectFirstItem(); } // Select items from last selected item to first item. else { // Found last selected index and do select operation. int lastSelectionIndex = d->renderItems->indexOf(d->lastSelectItem); shiftSelectItemsWithBound(0, lastSelectionIndex); // Scroll to top. d->renderOffset = d->getTopRenderOffset(); // Repaint. repaint(); } } void DSimpleListView::shiftSelectToNext() { D_D(DSimpleListView); shiftSelectNextItemWithOffset(1); } void DSimpleListView::shiftSelectToPrev() { D_D(DSimpleListView); shiftSelectPrevItemWithOffset(1); } void DSimpleListView::scrollPageDown() { D_D(DSimpleListView); selectNextItemWithOffset(getScrollAreaHeight() / d->rowHeight); } void DSimpleListView::scrollPageUp() { D_D(DSimpleListView); selectPrevItemWithOffset(getScrollAreaHeight() / d->rowHeight); } void DSimpleListView::ctrlScrollPageUp() { D_D(DSimpleListView); d->renderOffset = adjustRenderOffset(d->renderOffset - getScrollAreaHeight()); repaint(); } void DSimpleListView::ctrlScrollPageDown() { D_D(DSimpleListView); d->renderOffset = adjustRenderOffset(d->renderOffset + getScrollAreaHeight()); repaint(); } void DSimpleListView::ctrlScrollToHome() { D_D(DSimpleListView); d->renderOffset = d->getTopRenderOffset(); repaint(); } void DSimpleListView::ctrlScrollToEnd() { D_D(DSimpleListView); d->renderOffset = getBottomRenderOffset(); repaint(); } void DSimpleListView::leaveEvent(QEvent * event) { hideScrollbar(); QWidget::leaveEvent(event); } void DSimpleListView::hideScrollbar() { D_D(DSimpleListView); // Record old render offset to control scrollbar whether display. d->mouseAtScrollArea = false; d->oldRenderOffset = d->renderOffset; repaint(); } bool DSimpleListView::eventFilter(QObject *, QEvent *) { return false; } void DSimpleListView::keyPressEvent(QKeyEvent *keyEvent) { D_D(DSimpleListView); if (keyEvent->key() == Qt::Key_Home) { if (keyEvent->modifiers() == Qt::ControlModifier) { ctrlScrollToHome(); } else if (keyEvent->modifiers() == Qt::ShiftModifier) { shiftSelectToHome(); }else { selectFirstItem(); } } else if (keyEvent->key() == Qt::Key_End) { if (keyEvent->modifiers() == Qt::ControlModifier) { ctrlScrollToEnd(); } else if (keyEvent->modifiers() == Qt::ShiftModifier) { shiftSelectToEnd(); } else { selectLastItem(); } } else if (keyEvent->key() == Qt::Key_Up) { if (keyEvent->modifiers() == Qt::ShiftModifier) { shiftSelectToPrev(); } else { selectPrevItem(); } } else if (keyEvent->key() == Qt::Key_Down) { if (keyEvent->modifiers() == Qt::ShiftModifier) { shiftSelectToNext(); } else { selectNextItem(); } } else if (keyEvent->key() == Qt::Key_PageUp) { if (keyEvent->modifiers() == Qt::ControlModifier) { ctrlScrollPageUp(); } else if (keyEvent->modifiers() == Qt::ShiftModifier) { shiftSelectPageUp(); } else { scrollPageUp(); } } else if (keyEvent->key() == Qt::Key_PageDown) { if (keyEvent->modifiers() == Qt::ControlModifier) { ctrlScrollPageDown(); } else if (keyEvent->modifiers() == Qt::ShiftModifier) { shiftSelectPageDown(); } else { scrollPageDown(); } } else if (keyEvent->key() == Qt::Key_A) { if (keyEvent->modifiers() == Qt::ControlModifier) { selectAllItems(); } } } void DSimpleListView::mouseMoveEvent(QMouseEvent *mouseEvent) { D_D(DSimpleListView); // Scroll if mouse drag at scrollbar. if (d->mouseDragScrollbar) { int barHeight = getScrollbarHeight(); d->renderOffset = adjustRenderOffset((mouseEvent->y() - barHeight / 2 - d->titleHeight) / (getScrollAreaHeight() * 1.0) * d->getItemsTotalHeight()); repaint(); } // Update scrollbar status with mouse position. else if (isMouseAtScrollArea(mouseEvent->x()) != d->mouseAtScrollArea) { d->mouseAtScrollArea = isMouseAtScrollArea(mouseEvent->x()); repaint(); } // Otherwise to check titlebar arrow status. else { bool atTitleArea = isMouseAtTitleArea(mouseEvent->y()); if (atTitleArea) { int hoverColumn = -1; if (d->sortingAlgorithms->count() != 0 && d->sortingAlgorithms->count() == d->columnTitles.count() && d->sortingOrderes->count() == d->columnTitles.count()) { // Calcuate title widths; QList renderWidths = getRenderWidths(); int columnCounter = 0; int columnRenderX = 0; for (int renderWidth:renderWidths) { if (renderWidth > 0) { if (mouseEvent->x() > columnRenderX && mouseEvent->x() < columnRenderX + renderWidth) { hoverColumn = columnCounter; break; } columnRenderX += renderWidth; } columnCounter++; } } if (hoverColumn != d->titleHoverColumn) { d->titleHoverColumn = hoverColumn; repaint(); } } else { int hoverItemIndex = (d->renderOffset + mouseEvent->y() - d->titleHeight) / d->rowHeight; // NOTE: hoverItemIndex may be less than 0, we need check index here. if (hoverItemIndex >= 0 && hoverItemIndex < (*d->renderItems).length()) { DSimpleListItem *item = (*d->renderItems)[hoverItemIndex]; QList renderWidths = getRenderWidths(); int columnCounter = 0; int columnRenderX = 0; for (int renderWidth:renderWidths) { if (renderWidth > 0) { if (mouseEvent->x() > columnRenderX && mouseEvent->x() < columnRenderX + renderWidth) { break; } columnRenderX += renderWidth; } columnCounter++; } if (d->drawHoverItem == NULL || !item->sameAs(d->drawHoverItem)) { d->drawHoverItem = item; repaint(); } // Emit mouseHoverChanged signal. mouseHoverChanged(d->mouseHoverItem, item, columnCounter, QPoint(mouseEvent->x() - columnRenderX, d->renderOffset + mouseEvent->y() - hoverItemIndex * d->rowHeight)); d->mouseHoverItem = item; if (d->lastHoverItem == NULL || !item->sameAs(d->lastHoverItem) || columnCounter != d->lastHoverColumnIndex) { d->lastHoverItem = item; d->lastHoverColumnIndex = columnCounter; changeHoverItem(this->mapToGlobal(mouseEvent->pos()), d->lastHoverItem, columnCounter); } } } } } void DSimpleListView::mousePressEvent(QMouseEvent *mouseEvent) { D_D(DSimpleListView); setFocus(); bool atTitleArea = isMouseAtTitleArea(mouseEvent->y()); bool atScrollArea = isMouseAtScrollArea(mouseEvent->x()); // Sort items with column's sorting algorithms when click on title area. if (atTitleArea) { if (mouseEvent->button() == Qt::LeftButton) { if (d->sortingAlgorithms->count() != 0 && d->sortingAlgorithms->count() == d->columnTitles.count() && d->sortingOrderes->count() == d->columnTitles.count()) { // Calcuate title widths; QList renderWidths = getRenderWidths(); int columnCounter = 0; int columnRenderX = 0; for (int renderWidth:renderWidths) { if (renderWidth > 0) { if (mouseEvent->x() > columnRenderX && mouseEvent->x() < columnRenderX + renderWidth) { // If switch other column, default order is from top to bottom. if (columnCounter != d->defaultSortingColumn) { (*d->sortingOrderes)[columnCounter] = true; } // If user click same column, just switch reverse order. else { (*d->sortingOrderes)[columnCounter] = !(*d->sortingOrderes)[columnCounter]; } d->defaultSortingColumn = columnCounter; d->defaultSortingOrder = (*d->sortingOrderes)[columnCounter]; changeSortingStatus(d->defaultSortingColumn, d->defaultSortingOrder); d->sortItemsByColumn(columnCounter, (*d->sortingOrderes)[columnCounter]); if (columnCounter != d->titlePressColumn) { d->titlePressColumn = columnCounter; } repaint(); break; } columnRenderX += renderWidth; } columnCounter++; } } } else if (mouseEvent->button() == Qt::RightButton) { if (columnVisibles.count() == d->columnTitles.count()) { QMenu *menu = new QMenu(); menu->setStyle(QStyleFactory::create("dlight")); for (int i = 0; i < columnVisibles.count(); i++) { if (i != d->alwaysVisibleColumn) { QAction *action = new QAction(menu); action->setText(d->columnTitles[i]); action->setCheckable(true); action->setChecked(columnVisibles[i]); connect(action, &QAction::triggered, this, [this, action, i] { columnVisibles[i] = !columnVisibles[i]; changeColumnVisible(i, columnVisibles[i], columnVisibles); repaint(); }); menu->addAction(action); } } menu->exec(this->mapToGlobal(mouseEvent->pos())); } } } // Scroll when click on scrollbar area. else if (atScrollArea) { int barHeight = getScrollbarHeight(); int barY = getScrollbarY(); // Flag mouseDragScrollbar when click on scrollbar. if (mouseEvent->y() > barY && mouseEvent->y() < barY + barHeight) { d->mouseDragScrollbar = true; } // Scroll if click out of scrollbar area. else { d->renderOffset = adjustRenderOffset((mouseEvent->y() - barHeight / 2 - d->titleHeight) / (getScrollAreaHeight() * 1.0) * d->getItemsTotalHeight()); repaint(); } } // Select items. else { int pressItemIndex = (d->renderOffset + mouseEvent->y() - d->titleHeight) / d->rowHeight; if (pressItemIndex >= d->renderItems->count()) { clearSelections(); repaint(); } else { if (mouseEvent->button() == Qt::LeftButton) { if (pressItemIndex < d->renderItems->count()) { // Scattered selection of items when press ctrl modifier. if (mouseEvent->modifiers() == Qt::ControlModifier) { DSimpleListItem *item = (*d->renderItems)[pressItemIndex]; if (d->selectionItems->contains(item)) { d->selectionItems->removeOne(item); } else { QList items = QList(); items << item; addSelections(items); } } // Continuous selection of items when press shift modifier. else if ((mouseEvent->modifiers() == Qt::ShiftModifier) && !d->selectionItems->empty()) { int lastSelectionIndex = d->renderItems->indexOf(d->lastSelectItem); int selectionStartIndex = std::min(pressItemIndex, lastSelectionIndex); int selectionEndIndex = std::max(pressItemIndex, lastSelectionIndex); shiftSelectItemsWithBound(selectionStartIndex, selectionEndIndex); } // Just select item under mouse if user not press any modifier. else { clearSelections(); QList items = QList(); items << (*d->renderItems)[pressItemIndex]; addSelections(items); } // Emit mousePressChanged signal. QList renderWidths = getRenderWidths(); int columnCounter = 0; int columnRenderX = 0; for (int renderWidth:renderWidths) { if (renderWidth > 0) { if (mouseEvent->x() > columnRenderX && mouseEvent->x() < columnRenderX + renderWidth) { break; } columnRenderX += renderWidth; } columnCounter++; } mousePressChanged((*d->renderItems)[pressItemIndex], columnCounter, QPoint(mouseEvent->x() - columnRenderX, d->renderOffset + mouseEvent->y() - pressItemIndex * d->rowHeight)); repaint(); } } else if (mouseEvent->button() == Qt::RightButton) { DSimpleListItem *pressItem = (*d->renderItems)[pressItemIndex]; bool pressInSelectionArea = false; for (DSimpleListItem *item : *d->selectionItems) { if (item == pressItem) { pressInSelectionArea = true; break; } } if (!pressInSelectionArea && pressItemIndex < d->renderItems->length()) { clearSelections(); QList items = QList(); items << (*d->renderItems)[pressItemIndex]; addSelections(items); repaint(); } if (d->selectionItems->length() > 0) { rightClickItems(this->mapToGlobal(mouseEvent->pos()), *d->selectionItems); } } } } } void DSimpleListView::mouseReleaseEvent(QMouseEvent *mouseEvent) { D_D(DSimpleListView); if (d->mouseDragScrollbar) { // Reset mouseDragScrollbar. d->mouseDragScrollbar = false; repaint(); } else { if (d->titlePressColumn != -1) { d->titlePressColumn = -1; repaint(); } } // Emit mouseReleaseChanged signal. int releaseItemIndex = (d->renderOffset + mouseEvent->y() - d->titleHeight) / d->rowHeight; if (releaseItemIndex >= 0 && releaseItemIndex < (*d->renderItems).length()) { QList renderWidths = getRenderWidths(); int columnCounter = 0; int columnRenderX = 0; for (int renderWidth:renderWidths) { if (renderWidth > 0) { if (mouseEvent->x() > columnRenderX && mouseEvent->x() < columnRenderX + renderWidth) { break; } columnRenderX += renderWidth; } columnCounter++; } mouseReleaseChanged((*d->renderItems)[releaseItemIndex], columnCounter, QPoint(mouseEvent->x() - columnRenderX, d->renderOffset + mouseEvent->y() - releaseItemIndex * d->rowHeight)); } } void DSimpleListView::wheelEvent(QWheelEvent *event) { D_D(DSimpleListView); if (event->orientation() == Qt::Vertical) { // Record old render offset to control scrollbar whether display. d->oldRenderOffset = d->renderOffset; qreal scrollStep = event->angleDelta().y() / 120.0; d->renderOffset = adjustRenderOffset(d->renderOffset - scrollStep * d->scrollUnit); repaint(); } event->accept(); } void DSimpleListView::paintEvent(QPaintEvent *) { D_D(DSimpleListView); // Init. QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); // Calcuate title widths; QList renderWidths = getRenderWidths(); painter.setRenderHint(QPainter::Antialiasing, true); painter.setOpacity(0.05); int penWidth = 1; QPainterPath framePath; framePath.addRoundedRect(QRect(rect().x() + penWidth, rect().y() + penWidth, rect().width() - penWidth * 2, rect().height() - penWidth * 2), d->clipRadius, d->clipRadius); painter.setClipPath(framePath); // Draw title. if (d->titleHeight > 0) { QPainterPath titlePath; titlePath.addRect(QRectF(rect().x(), rect().y(), rect().width(), d->titleHeight)); painter.setOpacity(titleAreaOpacity); painter.fillPath(titlePath, QColor(titleAreaColor)); } int renderY = 0; int renderHeight = 0; if (d->titleHeight > 0) { int columnCounter = 0; int columnRenderX = 0; for (int renderWidth:renderWidths) { if (renderWidth > 0) { painter.setOpacity(1); QFont font = painter.font() ; font.setPointSize(titleSize); painter.setFont(font); painter.setPen(QPen(QColor(titleColor))); painter.drawText(QRect(columnRenderX + d->titlePadding, 0, renderWidth, d->titleHeight), Qt::AlignVCenter | Qt::AlignLeft, d->columnTitles[columnCounter]); columnRenderX += renderWidth; if (columnCounter < renderWidths.size() - 1) { painter.setOpacity(0.05); QPainterPath separatorPath; separatorPath.addRect(QRectF(rect().x() + columnRenderX - 1, rect().y() + 4, 1, d->titleHeight - 8)); painter.fillPath(separatorPath, QColor(titleLineColor)); } // Draw sort arrow. if (d->defaultSortingColumn == columnCounter) { painter.setOpacity(1); int arrowX = rect().x() + columnRenderX - d->titleArrowPadding - arrowUpNormalImage.width() / arrowUpNormalImage.devicePixelRatio(); int arrowY = rect().y() + (d->titleHeight - arrowDownNormalImage.height() / arrowUpNormalImage.devicePixelRatio()) / 2; if (d->defaultSortingOrder) { if (d->titlePressColumn == d->defaultSortingColumn) { painter.drawPixmap(QPoint(arrowX, arrowY), arrowDownPressImage); } else if (d->titleHoverColumn == d->defaultSortingColumn) { painter.drawPixmap(QPoint(arrowX, arrowY), arrowDownHoverImage); } else { painter.drawPixmap(QPoint(arrowX, arrowY), arrowDownNormalImage); } } else { if (d->titlePressColumn == d->defaultSortingColumn) { painter.drawPixmap(QPoint(arrowX, arrowY), arrowUpPressImage); } else if (d->titleHoverColumn == d->defaultSortingColumn) { painter.drawPixmap(QPoint(arrowX, arrowY), arrowUpHoverImage); } else { painter.drawPixmap(QPoint(arrowX, arrowY), arrowUpNormalImage); } } } } columnCounter++; } renderY += d->titleHeight; renderHeight += d->titleHeight; } // Draw background. painter.setOpacity(backgroundOpacity); QPainterPath backgroundPath; backgroundPath.addRect(QRectF(rect().x(), rect().y() + d->titleHeight, rect().width(), rect().height() - d->titleHeight)); painter.fillPath(backgroundPath, QColor(backgroundColor)); // Draw context. QPainterPath scrollAreaPath; scrollAreaPath.addRect(QRectF(rect().x(), rect().y() + d->titleHeight, rect().width(), getScrollAreaHeight())); int rowCounter = 0; for (DSimpleListItem *item:*d->renderItems) { if (rowCounter >= d->renderOffset / d->rowHeight) { // Clip item rect. QPainterPath itemPath; itemPath.addRect(QRect(0, renderY + rowCounter * d->rowHeight - d->renderOffset, rect().width(), d->rowHeight)); painter.setClipPath((framePath.intersected(scrollAreaPath)).intersected(itemPath)); // Draw item backround. bool isSelect = d->selectionItems->contains(item); bool isHover = d->drawHoverItem != NULL && item->sameAs(d->drawHoverItem); painter.save(); item->drawBackground(QRect(0, renderY + rowCounter * d->rowHeight - d->renderOffset, rect().width(), d->rowHeight), &painter, rowCounter, isSelect, isHover); painter.restore(); // Draw item foreground. int columnCounter = 0; int columnRenderX = 0; for (int renderWidth:renderWidths) { if (renderWidth > 0) { painter.save(); item->drawForeground(QRect(columnRenderX, renderY + rowCounter * d->rowHeight - d->renderOffset, renderWidth, d->rowHeight), &painter, columnCounter, rowCounter, isSelect, isHover); painter.restore(); columnRenderX += renderWidth; } columnCounter++; } renderHeight += d->rowHeight; if (renderHeight > rect().height()) { break; } } rowCounter++; } // Keep clip area. painter.setClipPath(framePath); // Draw search tooltip. if (d->searchContent != "" && d->renderItems->size() == 0) { painter.setOpacity(1); painter.setPen(QPen(QColor(searchColor))); QFont font = painter.font() ; font.setPointSize(20); painter.setFont(font); painter.drawText(QRect(rect().x(), rect().y() + d->titleHeight, rect().width(), rect().height() - d->titleHeight), Qt::AlignCenter, QObject::tr("No search result")); } // Draw frame. if (d->drawFrame) { QPen framePen; framePen.setColor(frameColor); painter.setOpacity(frameOpacity); painter.drawPath(framePath); } // Draw scrollbar. if (d->mouseAtScrollArea) { paintScrollbar(&painter); } else if (d->oldRenderOffset != d->renderOffset) { paintScrollbar(&painter); startScrollbarHideTimer(); } } void DSimpleListView::paintScrollbar(QPainter *painter) { D_D(DSimpleListView); if (d->getItemsTotalHeight() > getScrollAreaHeight()) { // Init scrollbar opacity with scrollbar status. qreal barOpacitry = 0; qreal barFrameOpacitry = 0; // Press. if (d->mouseDragScrollbar) { barOpacitry = scrollbarPressOpacity; barFrameOpacitry = scrollbarFramePressOpacity; } else { // Hover. if (d->mouseAtScrollArea) { barOpacitry = scrollbarHoverOpacity; barFrameOpacitry = scrollbarFrameHoverOpacity; } // Normal. else { barOpacitry = scrollbarNormalOpacity; barFrameOpacitry = scrollbarFrameNormalOpacity; } } int barWidth = (d->mouseAtScrollArea || d->mouseDragScrollbar) ? d->scrollbarDragWidth : d->scrollbarDefaultWidth; int barRadius = 4; int barY = getScrollbarY(); int barHeight = getScrollbarHeight(); painter->setOpacity(barOpacitry); QPainterPath path; path.addRoundedRect( QRectF(rect().x() + rect().width() - barWidth - d->scrollbarPadding, barY + barRadius, barWidth, barHeight - barRadius * 2), barRadius, barRadius); painter->fillPath(path, QColor(scrollbarColor)); QPen pen; pen.setColor(QColor(scrollbarColor)); pen.setWidth(1); painter->setOpacity(barFrameOpacitry); painter->setPen(pen); painter->drawPath(path); } } void DSimpleListView::selectNextItemWithOffset(int scrollOffset) { D_D(DSimpleListView); // Record old render offset to control scrollbar whether display. d->oldRenderOffset = d->renderOffset; if (d->selectionItems->empty()) { selectFirstItem(); } else { int lastIndex = 0; for (DSimpleListItem *item:*d->selectionItems) { int index = d->renderItems->indexOf(item); if (index > lastIndex) { lastIndex = index; } } if (lastIndex != -1) { lastIndex = std::min(d->renderItems->count() - 1, lastIndex + scrollOffset); clearSelections(false); QList items = QList(); items << (*d->renderItems)[lastIndex]; addSelections(items); int itemIndex = lastIndex + 1; int itemOffset = adjustRenderOffset(itemIndex * d->rowHeight - rect().height() + d->titleHeight); if (((d->renderOffset + getScrollAreaHeight()) / d->rowHeight) < itemIndex) { d->renderOffset = itemOffset; } repaint(); } } } void DSimpleListView::selectPrevItemWithOffset(int scrollOffset) { D_D(DSimpleListView); // Record old render offset to control scrollbar whether display. d->oldRenderOffset = d->renderOffset; if (d->selectionItems->empty()) { selectFirstItem(); } else { int firstIndex = d->renderItems->count(); for (DSimpleListItem *item:*d->selectionItems) { int index = d->renderItems->indexOf(item); if (index < firstIndex) { firstIndex = index; } } if (firstIndex != -1) { firstIndex = std::max(0, firstIndex - scrollOffset); clearSelections(); QList items = QList(); items << (*d->renderItems)[firstIndex]; addSelections(items); int itemIndex = firstIndex - 1; int itemOffset = adjustRenderOffset(itemIndex * d->rowHeight + d->titleHeight); if ((d->renderOffset / d->rowHeight) > itemIndex) { d->renderOffset = itemOffset; } repaint(); } } } void DSimpleListView::shiftSelectItemsWithBound(int selectionStartIndex, int selectionEndIndex) { D_D(DSimpleListView); // Note: Shift operation always selection bound from last selection index to current index. // So we don't need *clear* lastSelectionIndex for keep shift + button is right logic. clearSelections(false); QList items = QList(); int index = 0; for (DSimpleListItem *item:*d->renderItems) { if (index >= selectionStartIndex && index <= selectionEndIndex) { items << item; } index++; } // Note: Shift operation always selection bound from last selection index to current index. // So we don't need *record* lastSelectionIndex for keep shift + button is right logic. addSelections(items, false); } void DSimpleListView::shiftSelectPrevItemWithOffset(int scrollOffset) { D_D(DSimpleListView); // Record old render offset to control scrollbar whether display. d->oldRenderOffset = d->renderOffset; if (d->selectionItems->empty()) { selectFirstItem(); } else { int firstIndex = d->renderItems->count(); int lastIndex = 0; for (DSimpleListItem *item:*d->selectionItems) { int index = d->renderItems->indexOf(item); if (index < firstIndex) { firstIndex = index; } if (index > lastIndex) { lastIndex = index; } } if (firstIndex != -1) { int lastSelectionIndex = d->renderItems->indexOf(d->lastSelectItem); int selectionStartIndex, selectionEndIndex; if (lastIndex == lastSelectionIndex) { selectionStartIndex = std::max(0, firstIndex - scrollOffset); selectionEndIndex = lastSelectionIndex; } else { selectionStartIndex = firstIndex; selectionEndIndex = std::max(0, lastIndex - scrollOffset); } shiftSelectItemsWithBound(selectionStartIndex, selectionEndIndex); if (d->renderOffset / d->rowHeight >= selectionStartIndex) { d->renderOffset = adjustRenderOffset((selectionStartIndex - 1) * d->rowHeight + d->titleHeight); } repaint(); } } } void DSimpleListView::shiftSelectNextItemWithOffset(int scrollOffset) { D_D(DSimpleListView); // Record old render offset to control scrollbar whether display. d->oldRenderOffset = d->renderOffset; if (d->selectionItems->empty()) { selectFirstItem(); } else { int firstIndex = d->renderItems->count(); int lastIndex = 0; for (DSimpleListItem *item:*d->selectionItems) { int index = d->renderItems->indexOf(item); if (index < firstIndex) { firstIndex = index; } if (index > lastIndex) { lastIndex = index; } } if (firstIndex != -1) { int lastSelectionIndex = d->renderItems->indexOf(d->lastSelectItem); int selectionStartIndex, selectionEndIndex; if (firstIndex == lastSelectionIndex) { selectionStartIndex = firstIndex; selectionEndIndex = std::min(d->renderItems->count() - 1, lastIndex + scrollOffset); } else { selectionStartIndex = std::min(d->renderItems->count() - 1, firstIndex + scrollOffset); selectionEndIndex = lastIndex; } shiftSelectItemsWithBound(selectionStartIndex, selectionEndIndex); if ((d->renderOffset + rect().height()) / d->rowHeight <= selectionEndIndex + 1) { d->renderOffset = adjustRenderOffset((selectionEndIndex + 1) * d->rowHeight + d->titleHeight - rect().height()); } repaint(); } } } QList DSimpleListView::getRenderWidths() { D_D(DSimpleListView); QList renderWidths; if (d->columnWidths.length() > 0) { if (d->columnWidths.contains(-1)) { for (int i = 0; i < d->columnWidths.count(); i++) { if (d->columnWidths[i] != -1) { if (columnVisibles[i]) { renderWidths << d->columnWidths[i]; } else { renderWidths << 0; } } else { if (columnVisibles[i]) { int totalWidthOfOtherColumns = 0; for (int j = 0; j < d->columnWidths.count(); j++) { if (d->columnWidths[j] != -1 && columnVisibles[j]) { totalWidthOfOtherColumns += d->columnWidths[j]; } } renderWidths << rect().width() - totalWidthOfOtherColumns; } else { renderWidths << 0; } } } } else { for (int i = 0; i < d->columnWidths.count(); i++) { if (columnVisibles[i]) { renderWidths << d->columnWidths[i]; } else { renderWidths << 0; } } } } // Return widget width if user don't set column withs throught function 'setColumnTitleInfo'. // Avoid listview don't draw item's foregound cause by emptry 'columnWidths'. else { renderWidths << rect().width(); } return renderWidths; } bool DSimpleListView::isMouseAtScrollArea(int x) { D_D(DSimpleListView); return (x > rect().x() + rect().width() - d->scrollbarDragWidth) && (x < rect().x() + rect().width()); } bool DSimpleListView::isMouseAtTitleArea(int y) { D_D(DSimpleListView); return (y > rect().y() && y < rect().y() + d->titleHeight); } int DSimpleListView::adjustRenderOffset(int offset) { return std::max(0, std::min(offset, getBottomRenderOffset())); } int DSimpleListViewPrivate::getItemsTotalHeight() { return renderItems->count() * rowHeight; } int DSimpleListView::getScrollAreaHeight() { D_D(DSimpleListView); return rect().height() - d->titleHeight; } int DSimpleListView::getScrollbarY() { D_D(DSimpleListView); int y = static_cast((d->renderOffset / (d->getItemsTotalHeight() * 1.0)) * getScrollAreaHeight() + d->titleHeight); return qMin(y, rect().height() - getScrollbarHeight()); } int DSimpleListView::getScrollbarHeight() { D_D(DSimpleListView); return std::max(static_cast(getScrollAreaHeight() / (d->getItemsTotalHeight() * 1.0) * rect().height()), d->scrollbarMinHeight); } int DSimpleListViewPrivate::getTopRenderOffset() { return 0; } QList DSimpleListViewPrivate::getSearchItems(QList items) { if (searchContent == "" || searchAlgorithm == NULL) { return items; } else { QList *searchItems = new QList(); for (DSimpleListItem *item : items) { if (searchAlgorithm(item, searchContent)) { searchItems->append(item); } } return *searchItems; } } int DSimpleListView::getBottomRenderOffset() { D_D(DSimpleListView); int itemsHeight = d->getItemsTotalHeight(); if (itemsHeight > rect().height() - d->titleHeight) { return d->getItemsTotalHeight() - rect().height() + d->titleHeight; } else { return 0; } } void DSimpleListViewPrivate::sortItemsByColumn(int column, bool descendingSort) { if (sortingAlgorithms->count() != 0 && sortingAlgorithms->count() == columnTitles.count() && sortingOrderes->count() == columnTitles.count()) { qSort(renderItems->begin(), renderItems->end(), [&](const DSimpleListItem *item1, const DSimpleListItem *item2) { return (*sortingAlgorithms)[column](item1, item2, descendingSort); }); } } void DSimpleListView::startScrollbarHideTimer() { D_D(DSimpleListView); if (d->hideScrollbarTimer != NULL) { d->hideScrollbarTimer->stop(); } d->hideScrollbarTimer = new QTimer(); connect(d->hideScrollbarTimer, SIGNAL(timeout()), this, SLOT(hideScrollbar())); d->hideScrollbarTimer->start(d->hideScrollbarDuration); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dsimplelistview.h000066400000000000000000000214151325435343100215060ustar00rootroot00000000000000/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*- * -*- coding: utf-8 -*- * * Copyright (C) 2011 ~ 2017 Deepin, Inc. * 2011 ~ 2017 Wang Yong * * Author: Wang Yong * Maintainer: Wang Yong * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSIMPLELISTVIEW_H #define DSIMPLELISTVIEW_H #include "dobject.h" #include "dsimplelistitem.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE typedef bool (* SortAlgorithm) (const DSimpleListItem *item1, const DSimpleListItem *item2, bool descendingSort); typedef bool (* SearchAlgorithm) (const DSimpleListItem *item, QString searchContent); class DSimpleListViewPrivate; class LIBDTKWIDGETSHARED_EXPORT DSimpleListView : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: explicit DSimpleListView(QWidget *parent = 0); ~DSimpleListView(); // DSimpleListView interfaces. /* * Set row height of DSimpleListView. * * @height the height of row */ void setRowHeight(int height); /* * Set column titles, widths and height. * If you want some column use expand space, please set width with -1 * Only allowed one -1 to set in width list. * * @titles a list to contains titles * @widths the width of column, list length same as titles list * @height height of titlebar, don't display titlebar if set height with 0 */ void setColumnTitleInfo(QList titles, QList widths, int height); /* * Set column hide flags. * At least have false in hide flags list, and hide flags count must same as titles list. * * @toggleHideFlags the hide flags to control column wether toggle show/hide. * @alwaysVisibleColumn the column index that column is always visible, default is -1, mean no column can always visible. */ void setColumnHideFlags(QList toggleHideFlags, int alwaysVisibleColumn=-1); /* * Set column sorting algorithms. * Note SortAlgorithm function type must be 'static', otherwise function pointer can't match type. * * @algorithms a list of SortAlgorithm, SortAlgorithm is function pointer, it's type is: 'bool (*) (const DSimpleListItem *item1, const DSimpleListItem *item2, bool descendingSort)' * @sortColumn default sort column, -1 mean don't sort any column default * @descendingSort whether sort column descending, default is false */ void setColumnSortingAlgorithms(QList *algorithms, int sortColumn=-1, bool descendingSort=false); /* * Set search algorithm to filter match items. * * @algorithm the search algorithm, it's type is: 'bool (*) (const DSimpleListItem *item, QString searchContent)' */ void setSearchAlgorithm(SearchAlgorithm algorithm); /* * Set radius to clip listview. * * @radius the radius of clip area, default is 0 pixel. */ void setClipRadius(int radius); /* * Set frame details. * * @enableFrame draw frame if enableFrame is true, default is false * @color the frame color, default is black * @opacity the frame opacity, default is 0.1 */ void setFrame(bool enableFrame, QColor color=QColor("#000000"), double opacity=0.1); /* * Add DSimpleListItem list to ListView. * If user has click title to sort, sort items after add items to list. * * @items List of LiteItem* */ void addItems(QList items); /* * Remove DSimpleListItem from list. * * @item item to remove */ void removeItem(DSimpleListItem* item); /* * Clear items from DSimpleListView. */ void clearItems(); /* * Add DSimpleListItem list to mark selected effect in ListView. * * @items List of DSimpleListItem* to mark selected * @recordLastSelection record last selection item to make selected operation continuously, default is true */ void addSelections(QList items, bool recordLastSelection=true); /* * Clear selection items from DSimpleListView. * * @clearLastSelection clear last selection item if option is true, default is true */ void clearSelections(bool clearLastSelection=true); /* * Refresh all items in DSimpleListView. * This function is different that addItems is: it will clear items first before add new items. * This function will keep selection status and scroll offset when add items. * * @items List of DSimpleListItem* to add */ void refreshItems(QList items); /* * Search */ void search(QString searchContent); // DSimpleListView operations. void selectAllItems(); void selectFirstItem(); void selectLastItem(); void selectNextItem(); void selectPrevItem(); void shiftSelectPageDown(); void shiftSelectPageUp(); void shiftSelectToEnd(); void shiftSelectToHome(); void shiftSelectToNext(); void shiftSelectToPrev(); void scrollPageDown(); void scrollPageUp(); void ctrlScrollPageDown(); void ctrlScrollPageUp(); void ctrlScrollToEnd(); void ctrlScrollToHome(); protected: virtual void leaveEvent(QEvent * event); QPixmap arrowDownDarkHoverImage; QPixmap arrowDownDarkNormalImage; QPixmap arrowDownDarkPressImage; QPixmap arrowDownHoverImage; QPixmap arrowDownLightHoverImage; QPixmap arrowDownLightNormalImage; QPixmap arrowDownLightPressImage; QPixmap arrowDownNormalImage; QPixmap arrowDownPressImage; QPixmap arrowUpDarkHoverImage; QPixmap arrowUpDarkNormalImage; QPixmap arrowUpDarkPressImage; QPixmap arrowUpHoverImage; QPixmap arrowUpLightHoverImage; QPixmap arrowUpLightNormalImage; QPixmap arrowUpLightPressImage; QPixmap arrowUpNormalImage; QPixmap arrowUpPressImage; QString backgroundColor = "#ffffff"; QString scrollbarColor = "#ffffff"; QString searchColor = "#000000"; QString titleAreaColor = "#ffffff"; QString titleColor = "#000000"; QString titleLineColor = "#000000"; QColor frameColor = QColor("#000000"); double backgroundOpacity = 0.03; double frameOpacity = 0.1; double titleAreaOpacity = 0.02; int titleSize = 10; qreal scrollbarFrameHoverOpacity = 0; qreal scrollbarFrameNormalOpacity = 0; qreal scrollbarFramePressOpacity = 0; qreal scrollbarHoverOpacity = 0.7; qreal scrollbarNormalOpacity = 0.5; qreal scrollbarPressOpacity = 0.8; Q_SIGNALS: void rightClickItems(QPoint pos, QList items); void changeColumnVisible(int index, bool visible, QList columnVisibles); void changeSortingStatus(int index, bool sortingOrder); void changeHoverItem(QPoint pos, DSimpleListItem* item, int columnIndex); void mouseHoverChanged(DSimpleListItem* oldItem, DSimpleListItem* newItem, int columnIndex, QPoint pos); void mousePressChanged(DSimpleListItem* item, int columnIndex, QPoint pos); void mouseReleaseChanged(DSimpleListItem* item, int columnIndex, QPoint pos); protected: bool eventFilter(QObject *, QEvent *event); void keyPressEvent(QKeyEvent *keyEvent); void mouseMoveEvent(QMouseEvent *mouseEvent); void mousePressEvent(QMouseEvent *mouseEvent); void mouseReleaseEvent(QMouseEvent *mouseEvent); void paintEvent(QPaintEvent *); void wheelEvent(QWheelEvent *event); void paintScrollbar(QPainter *painter); void selectPrevItemWithOffset(int scrollOffset); void selectNextItemWithOffset(int scrollOffset); void shiftSelectNextItemWithOffset(int scrollOffset); void shiftSelectPrevItemWithOffset(int scrollOffset); int getBottomRenderOffset(); int getScrollbarY(); int getScrollAreaHeight(); int getScrollbarHeight(); QList getRenderWidths(); void shiftSelectItemsWithBound(int selectionStartIndex, int selectionEndIndex); int adjustRenderOffset(int offset); void startScrollbarHideTimer(); bool isMouseAtScrollArea(int x); bool isMouseAtTitleArea(int y); QList columnVisibles; private Q_SLOTS: void hideScrollbar(); private: D_DECLARE_PRIVATE(DSimpleListView) }; DWIDGET_END_NAMESPACE #endif dtkwidget-2.0.7.2/src/widgets/dslider.cpp000066400000000000000000000306371325435343100202510ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include "dslider.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE static const int CustomDrawingLeftPadding = 10; static const int CustomDrawingRightPadding = 10; static const int CustomDrawingScaleHeight = 6; // TODO: optimize for better vertical slider support class DSliderPrivate { DSliderPrivate(DSlider *q): m_hoverShowValue(false), m_handleHovering(false), m_hoverTimout(false), m_hoverShowValueInterval(-1), q_ptr(q) { m_hoverTimer.setSingleShot(true); } int m_handleType = DSlider::RoundHandle; QString m_leftTip; QString m_rightTip; QList m_scales; QColor m_tipColor = Qt::black; QColor m_scaleColor = Qt::black; QColor m_hoverValueColor; bool m_hoverShowValue; bool m_handleHovering; bool m_hoverTimout; bool mousePressed = false; int clickOffset = 0; int m_hoverShowValueInterval; QTimer m_hoverTimer; int getScalePosition(int value); int pixelPosToRangeValue(int pos) const; inline int pick(const QPoint &pt) const { Q_Q(const DSlider); return q->orientation() == Qt::Horizontal ? pt.x() : pt.y(); } DSlider *q_ptr; Q_DECLARE_PUBLIC(DSlider) }; /*! * \class DSlider * \brief The DSlider class provides an extended QSlider widget. * * DSlider has optional vernier type handle type, scale marks that can be placed at * any position and corresponding scale tips. * * DSlider also supports showing texts, value of the slider, when * user hovers on the slider handle. * * \note This class relies on dstyle Qt style plugin to work properly. * * \note This class is not working very well while orientaion is set to vertical. */ /*! * \brief DSlider::DSlider constructs an instance of DSlider. * \param parent is passed to QSlider constructor. */ DSlider::DSlider(QWidget *parent) : QSlider(parent), d_ptr(new DSliderPrivate(this)) { init(); } /*! * \brief DSlider::DSlider constructs an instance of DSlider. * \param orientation is passed to QSlider constructor. * \param parent is passed to QSldier constructor. */ DSlider::DSlider(Qt::Orientation orientation, QWidget *parent) : QSlider(orientation, parent), d_ptr(new DSliderPrivate(this)) { init(); } DSlider::~DSlider() { delete d_ptr; } /*! * \property DSlider::handleType * \brief This property holds the handle type used by this slider. * * Default value is DSlider::RoundHandle. */ int DSlider::handleType() const { Q_D(const DSlider); return d->m_handleType; } void DSlider::setHandleType(HandleType handleType) { Q_D(DSlider); d->m_handleType = handleType; } QString DSlider::rightTip() const { Q_D(const DSlider); return d->m_rightTip; } void DSlider::setRightTip(const QString &rightTip) { Q_D(DSlider); if (d->m_rightTip == rightTip) { return; } if (d->m_rightTip.isEmpty() || rightTip.isEmpty()) { d->m_rightTip = rightTip; updateGeometry(); } else { d->m_rightTip = rightTip; } repaint(); } /*! * \property DSlider::leftTip * \brief This property holds the text to be display on the left side of the slider. * * DSlider::leftTip and DSlider::rightTip are used to help the user understand * how the slider works, for example: leftTip set to Low and rightTip set to High * tells the user that drag the handle to left lower the value and vice versa. */ QString DSlider::leftTip() const { Q_D(const DSlider); return d->m_leftTip; } void DSlider::setLeftTip(const QString &leftTip) { Q_D(DSlider); if (d->m_leftTip == leftTip) { return; } if (d->m_leftTip.isEmpty() || leftTip.isEmpty()) { d->m_leftTip = leftTip; updateGeometry(); } else { d->m_leftTip = leftTip; } repaint(); } /*! * \property DSlider::scaleColor * \brief This property holds the color to paint the scale marks. */ QColor DSlider::scaleColor() const { Q_D(const DSlider); return d->m_scaleColor; } void DSlider::setScaleColor(const QColor &scaleColor) { Q_D(DSlider); d->m_scaleColor = scaleColor; repaint(); } /*! * \property DSlider::tipColor * \brief This property holds the color to paint the scale tips. */ QColor DSlider::tipColor() const { Q_D(const DSlider); return d->m_tipColor; } void DSlider::setTipColor(const QColor &tipColor) { Q_D(DSlider); d->m_tipColor = tipColor; repaint(); } /*! * \brief DSlider::addScale adds a scale mark on the slider. * \param value is the position that the scale mark to be added. * * The scale added can be removed using DSlider::removeScale passing the * value as the parameter. */ void DSlider::addScale(int value) { Q_D(DSlider); d->m_scales.append(value); if (d->m_scales.count() == 1) { updateGeometry(); } repaint(); } /*! * \brief DSlider::removeScale removes a scale mark on the slider. * \param value is the value used to add the scale mark. */ void DSlider::removeScale(int value) { Q_D(DSlider); d->m_scales.removeOne(value); if (d->m_scales.isEmpty()) { updateGeometry(); } repaint(); } void DSlider::mousePressEvent(QMouseEvent *event) { QAbstractSlider::mousePressEvent(event); if (event->button() == Qt::LeftButton) { if (orientation() == Qt::Vertical) { setValue(minimum() + ((maximum() - minimum()) * (height() - event->y())) / height()) ; } else { // FIXME // the value 10 is specified in DSlider.theme, it's ugly here, but I don't have any // good idea for now, maybe someone can help. setValue(minimum() + ((maximum() - minimum()) * (event->x() - 10)) / (width() - 10 - 10)) ; } event->accept(); Q_D(DSlider); QStyleOptionSlider opt; initStyleOption(&opt); setRepeatAction(SliderNoAction); QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); d->clickOffset = d->pick(event->pos() - sr.topLeft()); d->mousePressed = true; Q_EMIT sliderPressed(); } } void DSlider::mouseReleaseEvent(QMouseEvent *event) { QAbstractSlider::mouseReleaseEvent(event); if(event->button() == Qt::LeftButton) { d_func()->mousePressed = false; Q_EMIT sliderReleased(); } } void DSlider::paintEvent(QPaintEvent *event) { Q_D(DSlider); QPainter painter; painter.begin(this); // draw tips QFont font = painter.font(); font.setPixelSize(12); painter.setFont(font); QPen pen = painter.pen(); pen.setColor(d->m_tipColor); painter.setPen(pen); QRect tmp = rect().adjusted(CustomDrawingLeftPadding - 5, 0, -CustomDrawingRightPadding + 5, 0); QTextOption leftBottomOption; leftBottomOption.setAlignment(Qt::AlignLeft | Qt::AlignBottom); painter.drawText(tmp, d->m_leftTip, leftBottomOption); QTextOption rightBottomOption; rightBottomOption.setAlignment(Qt::AlignRight | Qt::AlignBottom); painter.drawText(tmp, d->m_rightTip, rightBottomOption); // draw scales pen.setColor(d->m_scaleColor); painter.setPen(pen); Q_FOREACH(int scale, d->m_scales) { int x = d->getScalePosition(scale); int y = height() - 8; painter.drawLine(x, y, x, y - CustomDrawingScaleHeight); } if (d->m_handleHovering && !d->m_hoverTimout) { QString str = QString::number(value()); int x = d->getScalePosition(value()) - painter.fontMetrics().width(str) / 2.0; painter.setPen(d->m_hoverValueColor); painter.drawText(x, 10, str); } painter.end(); QSlider::paintEvent(event); } void DSlider::mouseMoveEvent(QMouseEvent *event) { Q_D(DSlider); if(d->mousePressed) { int newPosition = d->pixelPosToRangeValue(d->pick(event->pos()) - d->clickOffset); setSliderPosition(newPosition); Q_EMIT sliderMoved(newPosition); } if (!d->m_hoverShowValue) { return; } QPoint pos = event->pos(); QRect rect(d->getScalePosition(value()) - CustomDrawingLeftPadding, 10, 20, 20); if (d->m_handleHovering) { d->m_handleHovering = rect.contains(pos); } else { d->m_handleHovering = rect.contains(pos); if (d->m_handleHovering) { d->m_hoverTimout = false; if (d->m_hoverShowValueInterval > 0) { d->m_hoverTimer.start(d->m_hoverShowValueInterval); } } } update(); } void DSlider::hoverTimout() { Q_D(DSlider); d->m_hoverTimout = true; update(); } void DSlider::init() { Q_D(DSlider); DThemeManager::registerWidget(this); setMouseTracking(true); connect(&d->m_hoverTimer, &QTimer::timeout, this, &DSlider::hoverTimout); } QSize DSlider::sizeHint() const { Q_D(const DSlider); QSize size = QSlider::sizeHint(); if (!d->m_leftTip.isEmpty() || !d->m_rightTip.isEmpty() || !d->m_scales.isEmpty()) { size.setHeight(size.height() + 25); } else { if (d->m_hoverShowValue) { size.setHeight(size.height() + 25); } else { size.setHeight(size.height() + 3); } } return size; } /*! * \property DSlider::hoverShowValue * \brief This property holds whether the value should be displayed when user * hovers on the slider handle. */ bool DSlider::hoverShowValue() const { Q_D(const DSlider); return d->m_hoverShowValue; } /*! * \property DSlider::hoverValueColor * \brief This property holds the color to be used to display the texts. */ QColor DSlider::hoverValueColor() const { Q_D(const DSlider); return d->m_hoverValueColor; } /*! * \property DSlider::hoverShowValueInterval * \brief This property holds the interval of how long the value will be displayed * if the user keeps hovering on the slider handle. */ int DSlider::hoverShowValueInterval() const { Q_D(const DSlider); return d->m_hoverShowValueInterval; } void DSlider::setHoverShowValue(bool hoverShowValue) { Q_D(DSlider); if (d->m_hoverShowValue == hoverShowValue) { return; } d->m_hoverShowValue = hoverShowValue; d->m_handleHovering &= hoverShowValue; updateGeometry(); repaint(); } void DSlider::setHoverValueColor(QColor hoverValueColor) { Q_D(DSlider); d->m_hoverValueColor = hoverValueColor; } void DSlider::setHoverShowValueInterval(int hoverShowValueInterval) { Q_D(DSlider); d->m_hoverShowValueInterval = hoverShowValueInterval; } DSlider::DSlider(DSliderPrivate &d): d_ptr(&d) { init(); } int DSliderPrivate::getScalePosition(int value) { Q_Q(DSlider); float valueRange = q->maximum() - q->minimum(); float posRange = q->width() - CustomDrawingLeftPadding - CustomDrawingRightPadding; return CustomDrawingLeftPadding + (value - q->minimum()) * posRange / valueRange; } int DSliderPrivate::pixelPosToRangeValue(int pos) const { Q_Q(const DSlider); QStyleOptionSlider opt; q->initStyleOption(&opt); QRect gr = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, q); QRect sr = q->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, q); int sliderMin, sliderMax, sliderLength; if (q->orientation() == Qt::Horizontal) { sliderLength = sr.width(); sliderMin = gr.x(); sliderMax = gr.right() - sliderLength + 1; } else { sliderLength = sr.height(); sliderMin = gr.y(); sliderMax = gr.bottom() - sliderLength + 1; } return QStyle::sliderValueFromPosition(q->minimum(), q->maximum(), pos - sliderMin, sliderMax - sliderMin, opt.upsideDown); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dslider.h000066400000000000000000000057301325435343100177120ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSLIDER_H #define DSLIDER_H #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DSliderPrivate; class LIBDTKWIDGETSHARED_EXPORT DSlider : public QSlider { Q_OBJECT Q_PROPERTY(int handleType READ handleType) Q_PROPERTY(QColor tipColor READ tipColor WRITE setTipColor) Q_PROPERTY(QColor scaleColor READ scaleColor WRITE setScaleColor) Q_PROPERTY(bool hoverShowValue READ hoverShowValue WRITE setHoverShowValue) Q_PROPERTY(QColor hoverValueColor READ hoverValueColor WRITE setHoverValueColor) Q_PROPERTY(int hoverShowValueInterval READ hoverShowValueInterval WRITE setHoverShowValueInterval) public: /*! * \brief The HandleType enum contains the handle types can be used by DSlider. */ enum HandleType { SharpHandler, /*!< Rectangle with one side replaced by an arrow, like handle on verniers */ RoundHandle /*!< Round shape handle */ }; DSlider(QWidget *parent = 0); DSlider(Qt::Orientation orientation, QWidget *parent = 0); ~DSlider(); int handleType() const; void setHandleType(HandleType handleType); QString leftTip() const; void setLeftTip(const QString &leftTip); QString rightTip() const; void setRightTip(const QString &rightTip); QColor tipColor() const; void setTipColor(const QColor &tipColor); QColor scaleColor() const; void setScaleColor(const QColor &scaleColor); void addScale(int value); void removeScale(int value); bool hoverShowValue() const; QColor hoverValueColor() const; int hoverShowValueInterval() const; public Q_SLOTS: void setHoverShowValue(bool hoverShowValue); void setHoverValueColor(QColor hoverValueColor); void setHoverShowValueInterval(int hoverShowValueInterval); protected: DSlider(DSliderPrivate &d); void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; QSize sizeHint() const Q_DECL_OVERRIDE; private Q_SLOTS: void hoverTimout(); private: DSliderPrivate *d_ptr; void init(); Q_DECLARE_PRIVATE(DSlider) Q_DISABLE_COPY(DSlider) }; DWIDGET_END_NAMESPACE #endif // DSLIDER_H dtkwidget-2.0.7.2/src/widgets/dspinbox.cpp000066400000000000000000000143671325435343100204530ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include "dspinbox.h" #include "dthememanager.h" #include "dlineedit.h" #include "private/dspinbox_p.h" #include "dimagebutton.h" DWIDGET_BEGIN_NAMESPACE DImageButton* DSpinBox_getButton(const QString &image_name) { const QString str = ":/images/" + DThemeManager::instance()->theme() + "/images/" + image_name; DImageButton *button = new DImageButton(str + "_normal.png", str + "_hover.png", str + "_press.png"); button->setObjectName("SpinBox_ImageButton"); return button; } DSpinBoxPrivate::DSpinBoxPrivate(DSpinBox *parent) : DObjectPrivate(parent) { } void DSpinBoxPrivate::init() { D_Q(DSpinBox); insideFrame = new QFrame(q); insideFrame->setObjectName("SpinBoxInsideFrame"); QHBoxLayout *h_layout = new QHBoxLayout(insideFrame); DImageButton *button_reset = DSpinBox_getButton("restore"); DImageButton *button_add = DSpinBox_getButton("spinner_increase"); DImageButton *button_sub = DSpinBox_getButton("spinner_decrease"); h_layout->setMargin(0); h_layout->setSpacing(0); h_layout->addStretch(); h_layout->addWidget(button_reset); h_layout->addWidget(button_add); h_layout->addWidget(button_sub); q->connect(button_reset, &DImageButton::clicked, q, [q, this] { if(defaultValue <= q->maximum() && defaultValue >= q->minimum()) q->setValue(defaultValue); else q->setValue(q->minimum()); }); q->connect(button_add, &DImageButton::clicked, q, &DSpinBox::stepUp); q->connect(button_sub, &DImageButton::clicked, q, &DSpinBox::stepDown); } void DSpinBoxPrivate::_q_resizeInsideFrame(const QSize &size) { insideFrame->setFixedWidth(size.width()); insideFrame->setFixedHeight(size.height() - 1); } /*! * \class DSpinBox * \brief The DSpinBox class provides deepin style QSpinBox. * * Like DLineEdit, this widget can be set on alert to warn the user that the * input is not correct. In addition, there's a DSpinBox::defaultValue property * can be used to set a default value on the widget. */ /*! * \brief DSpinBox::DSpinBox constructs an instance of DSpinBox * \param parent is passed to QSpinBox constructor */ DSpinBox::DSpinBox(QWidget *parent) : QSpinBox(parent), DObject(*new DSpinBoxPrivate(this)) { DThemeManager::registerWidget(this, QStringList({"alert"})); d_func()->init(); } /*! * \brief DSpinBox::lineEdit * \return the QLineEdit used by this spin box. */ QLineEdit *DSpinBox::lineEdit() const { return QSpinBox::lineEdit(); } /*! * \property DSpinBox::isAlert * \brief This property holds whether the widget on alert mode. */ bool DSpinBox::isAlert() const { D_DC(DSpinBox); return d->alert; } /*! * \property DSpinBox::defaultValue * \brief This property holds the default value of this spin box. */ int DSpinBox::defaultValue() const { return d_func()->defaultValue; } void DSpinBox::setAlert(bool alert) { D_D(DSpinBox); if(alert == d->alert) return; d->alert = alert; Q_EMIT alertChanged(alert); } void DSpinBox::setDefaultValue(int defaultValue) { D_D(DSpinBox); if (d->defaultValue == defaultValue) return; d->defaultValue = defaultValue; Q_EMIT defaultValueChanged(defaultValue); } void DSpinBox::resizeEvent(QResizeEvent *e) { QSpinBox::resizeEvent(e); d_func()->_q_resizeInsideFrame(e->size()); } DDoubleSpinBoxPrivate::DDoubleSpinBoxPrivate(DDoubleSpinBox *parent) : DObjectPrivate(parent) { } void DDoubleSpinBoxPrivate::init() { D_Q(DDoubleSpinBox); insideFrame = new QFrame(q); insideFrame->setObjectName("SpinBoxInsideFrame"); QHBoxLayout *h_layout = new QHBoxLayout(insideFrame); DImageButton *button_reset = DSpinBox_getButton("restore"); DImageButton *button_add = DSpinBox_getButton("spinner_increase"); DImageButton *button_sub = DSpinBox_getButton("spinner_decrease"); h_layout->setMargin(0); h_layout->setSpacing(0); h_layout->addStretch(); h_layout->addWidget(button_reset); h_layout->addWidget(button_add); h_layout->addWidget(button_sub); q->connect(button_reset, &DImageButton::clicked, q, [q, this] { if(defaultValue < q->maximum() && defaultValue > q->minimum()) q->setValue(defaultValue); else q->setValue(q->minimum()); }); q->connect(button_add, &DImageButton::clicked, q, &DSpinBox::stepUp); q->connect(button_sub, &DImageButton::clicked, q, &DSpinBox::stepDown); } void DDoubleSpinBoxPrivate::_q_resizeInsideFrame(const QSize &size) { insideFrame->setFixedWidth(size.width()); insideFrame->setFixedHeight(size.height() - 1); } DDoubleSpinBox::DDoubleSpinBox(QWidget *parent) : QDoubleSpinBox(parent), DObject(*new DDoubleSpinBoxPrivate(this)) { DThemeManager::registerWidget(this, QStringList({"alert"})); d_func()->init(); } bool DDoubleSpinBox::isAlert() const { D_DC(DDoubleSpinBox); return d->alert; } double DDoubleSpinBox::defaultValue() const { return d_func()->defaultValue; } void DDoubleSpinBox::setAlert(bool alert) { D_D(DDoubleSpinBox); if(alert == d->alert) return; d->alert = alert; Q_EMIT alertChanged(alert); } void DDoubleSpinBox::setDefaultValue(double defaultValue) { D_D(DDoubleSpinBox); if (d->defaultValue == defaultValue) return; d->defaultValue = defaultValue; Q_EMIT defaultValueChanged(defaultValue); } void DDoubleSpinBox::resizeEvent(QResizeEvent *e) { QDoubleSpinBox::resizeEvent(e); d_func()->_q_resizeInsideFrame(e->size()); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dspinbox.h000066400000000000000000000045311325435343100201100ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSPINBOX_H #define DSPINBOX_H #include #include "dtkwidget_global.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE class DSpinBoxPrivate; class LIBDTKWIDGETSHARED_EXPORT DSpinBox : public QSpinBox, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(bool alert READ isAlert WRITE setAlert NOTIFY alertChanged) Q_PROPERTY(int defaultValue READ defaultValue WRITE setDefaultValue NOTIFY defaultValueChanged) public: explicit DSpinBox(QWidget *parent = 0); QLineEdit *lineEdit() const; bool isAlert() const; int defaultValue() const; public Q_SLOTS: void setAlert(bool alert); void setDefaultValue(int defaultValue); Q_SIGNALS: void alertChanged(bool alert); void defaultValueChanged(int defaultValue); protected: void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DSpinBox) }; class DDoubleSpinBoxPrivate; class DDoubleSpinBox : public QDoubleSpinBox, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(bool alert READ isAlert WRITE setAlert NOTIFY alertChanged) Q_PROPERTY(double defaultValue READ defaultValue WRITE setDefaultValue NOTIFY defaultValueChanged) public: explicit DDoubleSpinBox(QWidget *parent = 0); bool isAlert() const; double defaultValue() const; public Q_SLOTS: void setAlert(bool alert); void setDefaultValue(double defaultValue); Q_SIGNALS: void alertChanged(bool alert); void defaultValueChanged(double defaultValue); protected: void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DDoubleSpinBox) double m_defaultValue; }; DWIDGET_END_NAMESPACE #endif // DSPINBOX_H dtkwidget-2.0.7.2/src/widgets/dspinner.cpp000066400000000000000000000061441325435343100204410ustar00rootroot00000000000000#include "dspinner.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE class DSpinnerPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: explicit DSpinnerPrivate(DSpinner *qq); QList createDefaultIndicatorColorList(QColor color); QTimer refreshTimer; double indicatorShadowOffset = 10; double currentDegree = 0.0; QList> indicatorColors; D_DECLARE_PUBLIC(DSpinner) }; DSpinnerPrivate::DSpinnerPrivate(DSpinner *qq) : DObjectPrivate(qq) { } DSpinner::DSpinner(QWidget *parent) : QWidget(parent), DObject(*new DSpinnerPrivate(this)) { Q_D(DSpinner); d->indicatorColors << d->createDefaultIndicatorColorList(QColor(200, 46, 255)); d->indicatorColors << d->createDefaultIndicatorColorList(QColor(207, 225, 0)); d->indicatorColors << d->createDefaultIndicatorColorList(QColor(0, 255, 241)); d->refreshTimer.setInterval(30); connect(&d->refreshTimer, &QTimer::timeout, this, [ = ]() { d->currentDegree += 14; update(); }); } DSpinner::~DSpinner() { } bool DSpinner::isPlaying() const { Q_D(const DSpinner); return d->refreshTimer.isActive(); } void DSpinner::start() { Q_D(DSpinner); d->refreshTimer.start(); } void DSpinner::stop() { Q_D(DSpinner); d->refreshTimer.stop(); } void DSpinner::setBackgroundColor(QColor color) { setAutoFillBackground(true); QPalette pal = palette(); pal.setColor(QPalette::Background, color); setPalette(pal); } void DSpinner::paintEvent(QPaintEvent *) { Q_D(DSpinner); QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing); auto degreeCurrent = d->currentDegree * 1.0; auto center = QRectF(rect()).center(); auto radius = qMin(rect().width(), rect().height()) / 2.0; auto indicatorRadius = radius / 2 / 2 * 1.1; auto indicatorDegreeDelta = 360 / d->indicatorColors.count(); for (int i = 0; i < d->indicatorColors.count(); ++i) { auto colors = d->indicatorColors.value(i); for (int j = 0; j < colors.count(); ++j) { degreeCurrent = d->currentDegree - j * d->indicatorShadowOffset + indicatorDegreeDelta * i; auto x = (radius - indicatorRadius) * qCos(qDegreesToRadians(degreeCurrent)); auto y = (radius - indicatorRadius) * qSin(qDegreesToRadians(degreeCurrent)); x = center.x() + x; y = center.y() + y; auto tl = QPointF(x - 1 * indicatorRadius, y - 1 * indicatorRadius); QRectF rf(tl.x(), tl.y(), indicatorRadius * 2, indicatorRadius * 2); QPainterPath path; path.addEllipse(rf); painter.fillPath(path, colors.value(j)); } } } QList DSpinnerPrivate::createDefaultIndicatorColorList(QColor color) { QList colors; QList opacitys; opacitys << 100 << 30 << 15 << 10 << 5 << 4 << 3 << 2 << 1; for (int i = 0; i < opacitys.count(); ++i) { color.setAlpha(255 * opacitys.value(i) / 100); colors << color; } return colors; } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dspinner.h000066400000000000000000000011621325435343100201010ustar00rootroot00000000000000#ifndef DSPINNER_H #define DSPINNER_H #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DSpinnerPrivate; class LIBDTKWIDGETSHARED_EXPORT DSpinner : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: explicit DSpinner(QWidget *parent = 0); ~DSpinner(); bool isPlaying() const; public Q_SLOTS: void start(); void stop(); void setBackgroundColor(QColor color); protected: void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DSpinner) }; DWIDGET_END_NAMESPACE #endif dtkwidget-2.0.7.2/src/widgets/dstackwidget.cpp000066400000000000000000000220741325435343100212740ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "dthememanager.h" #include "dstackwidget.h" #include "private/dstackwidget_p.h" DWIDGET_BEGIN_NAMESPACE DAbstractStackWidgetTransitionPrivate::DAbstractStackWidgetTransitionPrivate(DAbstractStackWidgetTransition *qq): DObjectPrivate(qq), animation(new QVariantAnimation(qq)) { } DAbstractStackWidgetTransitionPrivate::~DAbstractStackWidgetTransitionPrivate() { } void DAbstractStackWidgetTransitionPrivate::init() { Q_Q(DAbstractStackWidgetTransition); QObject::connect(animation, &QVariantAnimation::valueChanged, q, &DAbstractStackWidgetTransition::updateVariant); } DAbstractStackWidgetTransition::DAbstractStackWidgetTransition(QObject *parent): QObject(parent), DObject(*new DAbstractStackWidgetTransitionPrivate(this)) { d_func()->init(); } void DAbstractStackWidgetTransition::beginTransition(const TransitionInfo &info) { Q_D(DAbstractStackWidgetTransition); d->info = info; } QVariantAnimation *DAbstractStackWidgetTransition::animation() const { Q_D(const DAbstractStackWidgetTransition); return d->animation; } DAbstractStackWidgetTransition::DAbstractStackWidgetTransition(DAbstractStackWidgetTransitionPrivate &dd, QObject *parent): QObject(parent), DObject(dd) { d_func()->init(); } const DAbstractStackWidgetTransition::TransitionInfo &DAbstractStackWidgetTransition::info() const { Q_D(const DAbstractStackWidgetTransition); return d->info; } DSlideStackWidgetTransition::DSlideStackWidgetTransition(QObject *parent): DAbstractStackWidgetTransition(parent) { } void DSlideStackWidgetTransition::beginTransition(const TransitionInfo &info) { DAbstractStackWidgetTransition::beginTransition(info); info.oldWidget->move(0, 0); if(info.type == Push) { info.newWidget->move(info.stackWidget->width(), 0); } else if(info.type == Pop) { info.newWidget->move(-info.stackWidget->width(), 0); } info.oldWidget->show(); info.newWidget->show(); animation()->setStartValue(0); animation()->setEndValue(-info.newWidget->x()); animation()->start(); } void DSlideStackWidgetTransition::updateVariant(const QVariant &variant) { int x = variant.toInt(); info().oldWidget->move(x, 0); if(info().type == Push) { info().newWidget->move(info().stackWidget->width() + x, 0); } else if(info().type == Pop) { info().newWidget->move(x - info().stackWidget->width(), 0); } } DStackWidgetPrivate::DStackWidgetPrivate(DStackWidget *qq): DObjectPrivate(qq) { } DStackWidgetPrivate::~DStackWidgetPrivate() { } void DStackWidgetPrivate::init() { Q_Q(DStackWidget); currentIndex = -1; currentWidget = nullptr; transition = nullptr; q->setTransition(new DSlideStackWidgetTransition(q)); } void DStackWidgetPrivate::setCurrentIndex(int index) { if(index == currentIndex) return; Q_Q(DStackWidget); if(index >= 0 && index < widgetList.count()){ currentIndex = index; currentWidget = widgetList[index]; } else { currentIndex = -1; currentWidget = nullptr; } q->currentIndexChanged(index); q->currentWidgetChanged(currentWidget); } DStackWidget::DStackWidget(QWidget *parent) : QWidget(parent), DObject(*new DStackWidgetPrivate(this)) { DThemeManager::registerWidget(this); d_func()->init(); } bool DStackWidget::busy() const { Q_D(const DStackWidget); return d->transition->animation()->state() != QVariantAnimation::Stopped; } int DStackWidget::depth() const { Q_D(const DStackWidget); return d->widgetList.count(); } int DStackWidget::currentIndex() const { Q_D(const DStackWidget); return d->currentIndex; } QWidget *DStackWidget::currentWidget() const { Q_D(const DStackWidget); return d->currentWidget; } DAbstractStackWidgetTransition *DStackWidget::transition() const { Q_D(const DStackWidget); return d->transition; } int DStackWidget::animationDuration() const { Q_D(const DStackWidget); return d->transition->animation()->duration(); } QEasingCurve::Type DStackWidget::animationType() const { Q_D(const DStackWidget); return d->transition->animation()->easingCurve().type(); } int DStackWidget::pushWidget(QWidget *widget, bool enableTransition) { insertWidget(depth(), widget, enableTransition); return depth() - 1; } void DStackWidget::insertWidget(int depth, QWidget *widget, bool enableTransition) { Q_D(DStackWidget); widget->setParent(this); d->widgetList.insert(depth, widget); if(depth == this->depth() - 1) setCurrentIndex(depth, DAbstractStackWidgetTransition::Push, enableTransition); else d->setCurrentIndex(indexOf(currentWidget())); } void DStackWidget::popWidget(QWidget *widget, bool isDelete, int count, bool enableTransition) { Q_D(DStackWidget); int i = widget ? indexOf(widget) : currentIndex(); if(i < 0 || i >= depth()) return; bool current_widget_deleted = false; while(count-- > 0){ QWidget *tmp_widget = d->widgetList[i]; if(tmp_widget == currentWidget()) { current_widget_deleted = true; } else if(isDelete) { tmp_widget->deleteLater(); } d->widgetList.removeAt(i); } if(current_widget_deleted && isDelete){ if(enableTransition && depth()){ d->trashWidgetList << d->currentWidget; } else if(d->currentWidget) { d->currentWidget->deleteLater(); d->currentWidget = nullptr; } } setCurrentIndex(depth() - 1, DAbstractStackWidgetTransition::Pop, enableTransition && current_widget_deleted); } void DStackWidget::clear() { Q_D(DStackWidget); qDeleteAll(d->widgetList.begin(), d->widgetList.end()); d->widgetList.clear(); d->setCurrentIndex(-1); } int DStackWidget::indexOf(QWidget *widget) const { Q_D(const DStackWidget); return d->widgetList.indexOf(widget); } QWidget *DStackWidget::getWidgetByIndex(int index) const { Q_D(const DStackWidget); return d->widgetList[index]; } void DStackWidget::setCurrentIndex(int currentIndex, DAbstractStackWidgetTransition::TransitionType type, bool enableTransition) { Q_D(DStackWidget); if(enableTransition && currentWidget() && currentIndex >= 0) { DAbstractStackWidgetTransition::TransitionInfo info; info.stackWidget = this; info.oldWidget = currentWidget(); info.newWidget = getWidgetByIndex(depth() - 1); info.type = type; d->setCurrentIndex(currentIndex); d->transition->beginTransition(info); } else { if(currentWidget()) { currentWidget()->hide(); } d->setCurrentIndex(currentIndex); if(currentWidget()) { currentWidget()->move(0, 0); currentWidget()->show(); } Q_EMIT switchWidgetFinished(); } } void DStackWidget::setCurrentWidget(QWidget *currentWidget, DAbstractStackWidgetTransition::TransitionType type, bool enableTransition) { setCurrentIndex(indexOf(currentWidget), type, enableTransition); } void DStackWidget::setTransition(DAbstractStackWidgetTransition *transition) { Q_D(DStackWidget); if(d->transition){ d->transition->deleteLater(); } transition->setParent(this); d->transition = transition; connect(transition->animation(), &QVariantAnimation::stateChanged, this, [this, d](QAbstractAnimation::State newState, QAbstractAnimation::State oldState){ if(newState == QVariantAnimation::Stopped) { busyChanged(false); qDeleteAll(d->trashWidgetList); d->trashWidgetList.clear(); Q_EMIT switchWidgetFinished(); } else if(oldState == QVariantAnimation::Stopped) { busyChanged(true); } }); } void DStackWidget::setAnimationDuration(int animationDuration) { Q_D(DStackWidget); d->transition->animation()->setDuration(animationDuration); } void DStackWidget::setAnimationType(QEasingCurve::Type animationType) { Q_D(DStackWidget); d->transition->animation()->setEasingCurve(animationType); } DStackWidget::DStackWidget(DStackWidgetPrivate &dd, QWidget *parent): QWidget(parent), DObject(dd) { DThemeManager::registerWidget(this); d_func()->init(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dstackwidget.h000066400000000000000000000116051325435343100207370ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSTACKWIDGET_H #define DSTACKWIDGET_H #include #include #include "dobject.h" #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DStackWidget; class DAbstractStackWidgetTransitionPrivate; class DAbstractStackWidgetTransition : public QObject, public DTK_CORE_NAMESPACE::DObject { public: enum TransitionType{ Push, Pop }; struct TransitionInfo{ TransitionType type; DStackWidget *stackWidget = nullptr; QWidget *oldWidget = nullptr; QWidget *newWidget = nullptr; }; explicit DAbstractStackWidgetTransition(QObject *parent = 0); virtual void beginTransition(const TransitionInfo &info); virtual QVariantAnimation *animation() const; protected: virtual void updateVariant(const QVariant& variant) = 0; protected: explicit DAbstractStackWidgetTransition(DAbstractStackWidgetTransitionPrivate &dd, QObject *parent = 0); const TransitionInfo &info() const; private: D_DECLARE_PRIVATE(DAbstractStackWidgetTransition) }; class DSlideStackWidgetTransition : public DAbstractStackWidgetTransition { Q_OBJECT public: explicit DSlideStackWidgetTransition(QObject *parent = 0); void beginTransition(const TransitionInfo &info) Q_DECL_OVERRIDE; private Q_SLOTS: void updateVariant(const QVariant &variant) Q_DECL_OVERRIDE; }; class DStackWidgetPrivate; class DStackWidget : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT ///busy is true if a transition is running, and false otherwise. Q_PROPERTY(bool busy READ busy NOTIFY busyChanged FINAL) ///The number of widgets currently pushed onto the stack. Q_PROPERTY(int depth READ depth NOTIFY depthChanged FINAL) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(QWidget* currentWidget READ currentWidget WRITE setCurrentWidget NOTIFY currentWidgetChanged) Q_PROPERTY(DAbstractStackWidgetTransition* transition READ transition WRITE setTransition) Q_PROPERTY(int animationDuration READ animationDuration WRITE setAnimationDuration) Q_PROPERTY(QEasingCurve::Type animationType READ animationType WRITE setAnimationType) public: explicit DStackWidget(QWidget *parent = 0); bool busy() const; int depth() const; int currentIndex() const; QWidget* currentWidget() const; DAbstractStackWidgetTransition* transition() const; int animationDuration() const; QEasingCurve::Type animationType() const; public Q_SLOTS: int pushWidget(QWidget *widget, bool enableTransition = true); void insertWidget(int depth, QWidget *widget, bool enableTransition = true); /// If widget is nullptr, all widgets up to the currentIndex+count widgets will be popped. /// If not specified, all widgets up to the depthOf(widget)+count widgets will be popped. void popWidget(QWidget *widget = nullptr, bool isDelete = true, int count = 1, bool enableTransition = true); void clear(); int indexOf(QWidget *widget) const; QWidget* getWidgetByIndex(int index) const; void setCurrentIndex(int currentIndex, DAbstractStackWidgetTransition::TransitionType type = DAbstractStackWidgetTransition::Push, bool enableTransition = true); void setCurrentWidget(QWidget* currentWidget, DAbstractStackWidgetTransition::TransitionType type = DAbstractStackWidgetTransition::Push, bool enableTransition = true); void setTransition(DAbstractStackWidgetTransition* transition); void setAnimationDuration(int animationDuration); void setAnimationType(QEasingCurve::Type animationType); Q_SIGNALS: void busyChanged(bool busy); void depthChanged(int depth); void currentIndexChanged(int currentIndex); void currentWidgetChanged(QWidget* currentWidget); void widgetDepthChanged(QWidget *widget, int depth); void switchWidgetFinished(); protected: explicit DStackWidget(DStackWidgetPrivate &dd, QWidget *parent = 0); private: Q_DISABLE_COPY(DStackWidget) D_DECLARE_PRIVATE(DStackWidget) }; DWIDGET_END_NAMESPACE #endif // DSTACKWIDGET_H dtkwidget-2.0.7.2/src/widgets/dstyleoption.cpp000066400000000000000000000020021325435343100213410ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: zccrs * * Maintainer: zccrs * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dstyleoption.h" void DStyleOption::init(QWidget *widget) { Q_UNUSED(widget) } void DStyleOptionSuggestButton::init(QWidget *widget) { Q_UNUSED(widget) features |= QStyleOptionButton::ButtonFeature(SuggestButton); } dtkwidget-2.0.7.2/src/widgets/dstyleoption.h000066400000000000000000000022241325435343100210140ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: zccrs * * Maintainer: zccrs * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSTYLEOPTION_H #define DSTYLEOPTION_H #include class DStyleOption { public: virtual void init(QWidget *widget); }; class DStyleOptionSuggestButton : public QStyleOptionButton, public DStyleOption { public: enum ButtonFeature { SuggestButton = (CommandLinkButton << 1) }; void init(QWidget *widget) override; }; #endif // DSTYLEOPTION_H dtkwidget-2.0.7.2/src/widgets/dsuggestbutton.cpp000066400000000000000000000011401325435343100216670ustar00rootroot00000000000000#include "dsuggestbutton.h" #include "dstyleoption.h" #include #include DWIDGET_BEGIN_NAMESPACE DSuggestButton::DSuggestButton(QWidget *parent) : QPushButton(parent) { } DSuggestButton::DSuggestButton(const QString &text, QWidget *parent) : QPushButton(text, parent) { } void DSuggestButton::paintEvent(QPaintEvent *event) { QPushButton::paintEvent(event); QStylePainter p(this); DStyleOptionSuggestButton option; initStyleOption(&option); option.init(this); p.drawControl(QStyle::CE_PushButton, option); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dsuggestbutton.h000066400000000000000000000024511325435343100213420ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: zccrs * * Maintainer: zccrs * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSUGGESTBUTTON_H #define DSUGGESTBUTTON_H #include "dtkwidget_global.h" #include "dobject.h" #include DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DSuggestButton : public QPushButton, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: explicit DSuggestButton(QWidget *parent = nullptr); explicit DSuggestButton(const QString &text, QWidget *parent = nullptr); protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; }; DWIDGET_END_NAMESPACE #endif // DSUGGESTBUTTON_H dtkwidget-2.0.7.2/src/widgets/dswitchbutton.cpp000066400000000000000000000146441325435343100215240ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dswitchbutton.h" #include #include #include #include #include #include #include "dthememanager.h" #include "private/dswitchbutton_p.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DSwitchButton * \brief The DSwitchButton class provides switch like widget. * * User can put the switch on/off the turn some feature on/off. * * It's inspired by UISwitch of Apple, * see https://developer.apple.com/documentation/uikit/uiswitch. */ /*! * \brief DSwitchButton::DSwitchButton constructs an instance of DSwitchButton. * \param parent is passed to QFrame constructor. */ DSwitchButton::DSwitchButton(QWidget *parent) : QFrame(parent), DObject(*new DSwitchButtonPrivate(this)) { setObjectName("DSwitchButton"); setMaximumSize(38, 18); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); DThemeManager::registerWidget(this); D_D(DSwitchButton); d->init(); connect(d->m_innerAnimation, &QVariantAnimation::valueChanged, [&](){ this->update(); }); } /*! * \property DSwitchButton::checked * \brief This property holds whether the switch is on or off. * * True if the switch is on, otherwise false. */ bool DSwitchButton::checked() const { D_DC(DSwitchButton); return d->m_checked; } int DSwitchButton::animationDuration() const { D_DC(DSwitchButton); return d->m_innerAnimation->duration(); } QEasingCurve::Type DSwitchButton::animationType() const { D_DC(DSwitchButton); return d->m_innerAnimation->easingCurve().type(); } double DSwitchButton::animationStartValue() const { D_DC(DSwitchButton); return d->m_animationStartValue; } double DSwitchButton::animationEndValue() const { D_DC(DSwitchButton); return d->m_animationEndValue; } QString DSwitchButton::disabledImageSource() const { D_DC(DSwitchButton); return d->m_disabledImageSource; } QString DSwitchButton::enabledImageSource() const { D_DC(DSwitchButton); return d->m_enabledImageSource; } QSize DSwitchButton::sizeHint() const { return maximumSize(); } void DSwitchButton::setChecked(bool arg) { D_D(DSwitchButton); if (d->m_checked != arg) { d->m_checked = arg; if(arg){ d->m_innerAnimation->setStartValue(d->m_animationStartValue); d->m_innerAnimation->setEndValue(d->m_animationEndValue); }else{ d->m_innerAnimation->setStartValue(d->m_animationEndValue); d->m_innerAnimation->setEndValue(d->m_animationStartValue); } d->m_innerAnimation->start(); Q_EMIT checkedChanged(arg); } } void DSwitchButton::setAnimationDuration(int arg) { D_D(DSwitchButton); d->m_innerAnimation->setDuration(arg); } void DSwitchButton::setAnimationType(QEasingCurve::Type arg) { D_D(DSwitchButton); d->m_innerAnimation->setEasingCurve(arg); } bool DSwitchButton::setDisabledImageSource(const QString &arg) { D_D(DSwitchButton); d->m_disabledImageSource = arg; bool ok = false; d->m_disabledImage = d->loadPixmap(arg, ok); return ok; } bool DSwitchButton::setEnabledImageSource(const QString &arg) { D_D(DSwitchButton); d->m_enabledImageSource = arg; bool ok = false; d->m_enabledImage = d->loadPixmap(arg, ok); return ok; } void DSwitchButton::setAnimationStartValue(double animationStartValue) { D_D(DSwitchButton); d->m_animationStartValue = animationStartValue; } void DSwitchButton::setAnimationEndValue(double animationEndValue) { D_D(DSwitchButton); d->m_animationEndValue = animationEndValue; } void DSwitchButton::paintEvent(QPaintEvent *e) { Q_UNUSED(e); D_D(DSwitchButton); QPixmap m_innerImage; if(isEnabled()){ m_innerImage = d->m_enabledImage; }else{ m_innerImage = d->m_disabledImage; } if(m_innerImage.isNull()) return; QPainter p(this); p.setRenderHints(QPainter::Antialiasing); const qreal ratio = m_innerImage.devicePixelRatioF(); QPainterPath path; path.addRoundedRect(rect(), (m_innerImage.height() / 2.0) / ratio, (m_innerImage.height() / 2.0) / ratio); path.closeSubpath(); p.setClipPath(path); double m_innerImageX = 0; if(d->m_innerAnimation->state() == QVariantAnimation::Stopped){ if(!d->m_checked){ m_innerImageX = d->m_animationStartValue; } }else{ m_innerImageX = d->m_innerAnimation->currentValue().toDouble(); } p.drawPixmap(m_innerImageX, 0, m_innerImage); } void DSwitchButton::mousePressEvent(QMouseEvent *e) { D_D(DSwitchButton); if(e->button() == Qt::LeftButton){ setChecked(!d->m_checked); e->accept(); } } DSwitchButtonPrivate::DSwitchButtonPrivate(DSwitchButton *qq) : DObjectPrivate(qq) { init(); } DSwitchButtonPrivate::~DSwitchButtonPrivate() { m_innerAnimation->deleteLater(); } void DSwitchButtonPrivate::init() { m_checked = false; m_innerAnimation = new QVariantAnimation; m_animationStartValue = 0; m_animationEndValue = 0; } QPixmap DSwitchButtonPrivate::loadPixmap(const QString &path, bool &ok) { D_Q(DSwitchButton); QPixmap pixmap; qreal ratio = 1.0; const qreal devicePixel = q->devicePixelRatioF(); if (!qFuzzyCompare(ratio, devicePixel)) { ok = pixmap.load(qt_findAtNxFile(path, devicePixel, &ratio)); pixmap = pixmap.scaled(devicePixel / ratio * pixmap.width(), devicePixel / ratio * pixmap.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); pixmap.setDevicePixelRatio(devicePixel); } else { ok = pixmap.load(path); } return pixmap; } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dswitchbutton.h000066400000000000000000000056301325435343100211640ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSWITCHBUTTON_H #define DSWITCHBUTTON_H #include #include #include #include #include "dtkwidget_global.h" #include "dobject.h" DWIDGET_BEGIN_NAMESPACE class DSwitchButtonPrivate; class LIBDTKWIDGETSHARED_EXPORT DSwitchButton : public QFrame, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY checkedChanged) Q_PROPERTY(int animationDuration READ animationDuration WRITE setAnimationDuration) Q_PROPERTY(double animationStartValue READ animationStartValue WRITE setAnimationStartValue) Q_PROPERTY(double animationEndValue READ animationEndValue WRITE setAnimationEndValue) Q_PROPERTY(QEasingCurve::Type animationType READ animationType WRITE setAnimationType) Q_PROPERTY(QString disabledImageSource READ disabledImageSource WRITE setDisabledImageSource) Q_PROPERTY(QString enabledImageSource READ enabledImageSource WRITE setEnabledImageSource) public: explicit DSwitchButton(QWidget *parent = 0); bool checked() const; D_DECL_DEPRECATED int animationDuration() const; D_DECL_DEPRECATED QEasingCurve::Type animationType() const; D_DECL_DEPRECATED QString backgroundImageSource() const; D_DECL_DEPRECATED double animationStartValue() const; D_DECL_DEPRECATED double animationEndValue() const; D_DECL_DEPRECATED QString disabledImageSource() const; D_DECL_DEPRECATED QString enabledImageSource() const; QSize sizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: void setChecked(bool arg); D_DECL_DEPRECATED void setAnimationDuration(int arg); D_DECL_DEPRECATED void setAnimationType(QEasingCurve::Type arg); D_DECL_DEPRECATED void setAnimationStartValue(double animationStartValue); D_DECL_DEPRECATED void setAnimationEndValue(double animationEndValue); D_DECL_DEPRECATED bool setDisabledImageSource(const QString &arg); D_DECL_DEPRECATED bool setEnabledImageSource(const QString &arg); Q_SIGNALS: void checkedChanged(bool arg); protected: void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DSwitchButton) }; DWIDGET_END_NAMESPACE #endif // DSWITCHBUTTON_H dtkwidget-2.0.7.2/src/widgets/dswitchlineexpand.cpp000066400000000000000000000042041325435343100223270ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dswitchlineexpand.h" #include "dthememanager.h" #include DWIDGET_BEGIN_NAMESPACE SwitchHeaderLine::SwitchHeaderLine(QWidget *parent) : DHeaderLine(parent) { m_switchButton = new DSwitchButton(this); connect(m_switchButton, &DSwitchButton::checkedChanged, this, &SwitchHeaderLine::checkedChanged); setContent(m_switchButton); } void SwitchHeaderLine::setExpand(bool value) { m_switchButton->setChecked(value); } void SwitchHeaderLine::mousePressEvent(QMouseEvent *) { m_switchButton->setChecked(!m_switchButton->checked()); // Q_EMIT mousePress(); } DSwitchLineExpand::DSwitchLineExpand(QWidget *parent) : DBaseExpand(parent) { m_headerLine = new SwitchHeaderLine(this); m_headerLine->setExpand(expand()); connect(m_headerLine, &SwitchHeaderLine::checkedChanged, [ = ](bool arg) { DBaseExpand::setExpand(arg); }); setHeader(m_headerLine); } void DSwitchLineExpand::setTitle(const QString &title) { m_headerLine->setTitle(title); } void DSwitchLineExpand::setExpand(bool value) { //Header's arrow direction change here m_headerLine->setExpand(value); } DBaseLine *DSwitchLineExpand::header() { return m_headerLine; } void DSwitchLineExpand::setHeader(QWidget *header) { DBaseExpand::setHeader(header); } void DSwitchLineExpand::resizeEvent(QResizeEvent *e) { m_headerLine->setFixedWidth(e->size().width()); DBaseExpand::resizeEvent(e); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dswitchlineexpand.h000066400000000000000000000032221325435343100217730ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSWITCHLINEEXPAND_H #define DSWITCHLINEEXPAND_H #include #include "dtkwidget_global.h" #include "dbaseexpand.h" #include "dswitchbutton.h" #include "dheaderline.h" DWIDGET_BEGIN_NAMESPACE class SwitchHeaderLine : public DHeaderLine { Q_OBJECT public: SwitchHeaderLine(QWidget *parent = 0); void setExpand(bool value); Q_SIGNALS: void checkedChanged(bool arg); protected: void mousePressEvent(QMouseEvent *); private: void reverseArrowDirection(); DSwitchButton *m_switchButton = NULL; }; class LIBDTKWIDGETSHARED_EXPORT DSwitchLineExpand : public DBaseExpand { Q_OBJECT public: explicit DSwitchLineExpand(QWidget *parent = 0); void setTitle(const QString &title); void setExpand(bool value); DBaseLine *header(); private: void setHeader(QWidget *header); void resizeEvent(QResizeEvent *e); private: SwitchHeaderLine *m_headerLine = NULL; }; DWIDGET_END_NAMESPACE #endif // DSWITCHLINEEXPAND_H dtkwidget-2.0.7.2/src/widgets/dtabbar.cpp000066400000000000000000001331071325435343100202160ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: zccrs * * Maintainer: zccrs * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dtabbar.h" #include "dobject_p.h" #include "dimagebutton.h" #include "dthememanager.h" #include #include #include #include #include #include #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE inline static bool verticalTabs(QTabBar::Shape shape) { return shape == QTabBar::RoundedWest || shape == QTabBar::RoundedEast || shape == QTabBar::TriangularWest || shape == QTabBar::TriangularEast; } class DMovableTabWidget : public QWidget { public: explicit DMovableTabWidget(QWidget *parent = Q_NULLPTR); void setPixmap(const QPixmap &pixmap); protected: void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE; private: QPixmap m_pixmap; }; DMovableTabWidget::DMovableTabWidget(QWidget *parent) : QWidget(parent) { } void DMovableTabWidget::setPixmap(const QPixmap &pixmap) { m_pixmap = pixmap; update(); } void DMovableTabWidget::paintEvent(QPaintEvent *e) { Q_UNUSED(e) QPainter pa(this); pa.drawPixmap(0, 0, m_pixmap); } class DTabBarAddButton : public QToolButton { public: explicit DTabBarAddButton(QWidget *parent) : QToolButton(parent) {} private: void paintEvent(QPaintEvent *event) override; }; void DTabBarAddButton::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QStylePainter p(this); QStyleOptionToolButton opt; initStyleOption(&opt); p.drawControl(static_cast(QStyle::CE_CustomBase + 1), opt); } class DTabBarPrivate : public QTabBar, public DObjectPrivate { Q_OBJECT D_DECLARE_PUBLIC(DTabBar) public: explicit DTabBarPrivate(DTabBar* qq) : QTabBar(qq) , DObjectPrivate(qq) { startDragDistance = qApp->startDragDistance(); maskColor = flashColor = QColor(0, 0, 255, 125); addButton = new DTabBarAddButton(qq); addButton->setObjectName("AddButton"); addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); addButton->setFixedWidth(48); connect(addButton, &DTabBarAddButton::clicked, qq, &DTabBar::tabAddRequested); connect(this, &QTabBar::tabMoved, this, [this] (int from, int to) { tabMinimumSize.move(from, to); tabMaximumSize.move(from, to); }); setAcceptDrops(true); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding); QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); leftScrollButton = new QToolButton(qq); rightScrollButton = new QToolButton(qq); leftScrollButton->setVisible(d->leftB->isVisible()); leftScrollButton->setAutoRepeat(true); leftScrollButton->setArrowType(Qt::LeftArrow); leftScrollButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); rightScrollButton->setVisible(d->rightB->isVisible()); rightScrollButton->setAutoRepeat(true); rightScrollButton->setArrowType(Qt::RightArrow); rightScrollButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); d->leftB->setFixedSize(0, 0); d->leftB->installEventFilter(this); d->rightB->setFixedSize(0, 0); d->rightB->installEventFilter(this); connect(leftScrollButton, &QToolButton::clicked, d->leftB, &QToolButton::click); connect(rightScrollButton, &QToolButton::clicked, d->rightB, &QToolButton::click); QHBoxLayout *layout = new QHBoxLayout(qq); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addWidget(leftScrollButton); layout->addWidget(rightScrollButton); layout->addWidget(this); layout->addWidget(addButton); layout->addStretch(); qq->setFocusProxy(this); connect(this, &DTabBarPrivate::currentChanged, qq, &DTabBar::currentChanged); connect(this, &DTabBarPrivate::tabCloseRequested, qq, &DTabBar::tabCloseRequested); connect(this, &DTabBarPrivate::tabMoved, qq, &DTabBar::tabMoved); connect(this, &DTabBarPrivate::tabBarClicked, qq, &DTabBar::tabBarClicked); connect(this, &DTabBarPrivate::tabBarDoubleClicked, qq, &DTabBar::tabBarDoubleClicked); } void moveTabOffset(int index, int offset) { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); if (!d->validIndex(index)) return; d->tabList[index].dragOffset = offset; layoutTab(index); // Make buttons follow tab update(); } struct TabBarAnimation : public QVariantAnimation { TabBarAnimation(QTabBarPrivate::Tab *t, QTabBarPrivate *_priv, DTabBarPrivate *_dpriv) : tab(t), priv(_priv), dpriv(_dpriv) { setEasingCurve(QEasingCurve::InOutQuad); } void updateCurrentValue(const QVariant ¤t) Q_DECL_OVERRIDE { dpriv->moveTabOffset(priv->tabList.indexOf(*tab), current.toInt()); } void updateState(State, State newState) Q_DECL_OVERRIDE { if (newState == Stopped) dpriv->moveTabFinished(priv->tabList.indexOf(*tab)); } private: //these are needed for the callbacks QTabBarPrivate::Tab *tab; QTabBarPrivate *priv; DTabBarPrivate *dpriv; }; bool eventFilter(QObject *watched, QEvent *event) override; QSize minimumSizeHint() const override; void paintEvent(QPaintEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; void dragEnterEvent(QDragEnterEvent *e) override; void dragLeaveEvent(QDragLeaveEvent *e) override; void dragMoveEvent(QDragMoveEvent *e) override; void dropEvent(QDropEvent *e) override; void showEvent(QShowEvent *e) override; void resizeEvent(QResizeEvent *e) override; QSize tabSizeHint(int index) const override; QSize minimumTabSizeHint(int index) const override; virtual QSize maximumTabSizeHint(int index) const; void tabInserted(int index) override; void tabRemoved(int index) override; void tabLayoutChange() override; void initStyleOption(QStyleOptionTab *option, int tabIndex) const; Q_SLOT void startDrag(int tabIndex); void setupMovableTab(); void updateMoveingTabPosition(const QPoint &mouse); void setupDragableTab(); void slide(int from, int to); void layoutTab(int index); void moveTabFinished(int index); void layoutWidgets(int start = 0); void makeVisible(int index); void autoScrollTabs(const QPoint &mouse); void stopAutoScrollTabs(); void ensureScrollTabsAnimation(); void updateTabSize(); void startTabFlash(); void setDragingFromOther(bool v); int tabInsertIndexFromMouse(const QPoint &pos); QList tabMinimumSize; QList tabMaximumSize; bool visibleAddButton = true; DTabBarAddButton *addButton; QPointer drag; bool dragable = false; int startDragDistance; // 有从其它地方drag过来的标签页需要处理 bool dragingFromOther = false; // 记录当前drag过来的对象是否可以当做新标签页插入 bool canInsertFromDrag = false; QColor maskColor; QColor flashColor; // 要闪动绘制的Tab qreal opacityOnFlash = 1; int flashTabIndex = -1; QToolButton *leftScrollButton; QToolButton *rightScrollButton; class FullWidget : public QWidget { public: explicit FullWidget(QWidget *parent = 0) : QWidget(parent) {} void paintEvent(QPaintEvent *) override { QPainter pa(this); pa.fillRect(rect(), color); } QColor color; } *topFullWidget = nullptr; QVariantAnimation *scrollTabAnimation = nullptr; // 备份启动tab move时的QTabBarPrivate中的这两个值 int scrollOffset; QPoint dragStartPosition; }; void DTabBarPrivate::startDrag(int tabIndex) { Qt::DropAction action = drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::CopyAction); if (action == Qt::IgnoreAction) { Q_EMIT q_func()->tabReleaseRequested(tabIndex); } else if (drag->target() != this) { if (DTabBarPrivate *tbp = qobject_cast(drag->target())) Q_EMIT q_func()->tabDroped(tabIndex, action, tbp->q_func()); else Q_EMIT q_func()->tabDroped(tabIndex, action, drag->target()); } drag->setProperty("_d_DTabBarPrivate_drity", true); QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); // Be safe! if (d->dragInProgress && d->pressedIndex != -1) { d->hoverRect = QRect(); moveTabFinished(d->pressedIndex); } } void DTabBarPrivate::setupMovableTab() { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); if (!d->movingTab) d->movingTab = reinterpret_cast(new DMovableTabWidget(this)); int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); QRect grabRect = tabRect(d->pressedIndex); grabRect.adjust(-taboverlap, 0, taboverlap, 0); QPixmap grabImage(grabRect.size() * devicePixelRatioF()); grabImage.setDevicePixelRatio(devicePixelRatioF()); grabImage.fill(Qt::transparent); QPainter p(&grabImage); p.initFrom(this); QStyleOptionTab tab; initStyleOption(&tab, d->pressedIndex); tab.rect.moveTopLeft(QPoint(taboverlap, 0)); q_func()->paintTab(&p, d->pressedIndex, tab); reinterpret_cast(d->movingTab)->setPixmap(grabImage); d->movingTab->setGeometry(grabRect); d->movingTab->raise(); // Re-arrange widget order to avoid overlaps if (d->tabList[d->pressedIndex].leftWidget) d->tabList[d->pressedIndex].leftWidget->raise(); if (d->tabList[d->pressedIndex].rightWidget) d->tabList[d->pressedIndex].rightWidget->raise(); if (d->leftB) d->leftB->raise(); if (d->rightB) d->rightB->raise(); d->movingTab->setVisible(true); } void DTabBarPrivate::updateMoveingTabPosition(const QPoint &mouse) { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); bool vertical = verticalTabs(d->shape); int dragDistance; if (vertical) { dragDistance = (mouse.y() - d->dragStartPosition.y()); } else { dragDistance = (mouse.x() - d->dragStartPosition.x()); } if (!(d->pressedIndex == 0 && dragDistance < 0) && !(d->pressedIndex == d->tabList.count() - 1 && dragDistance > 0)) { d->tabList[d->pressedIndex].dragOffset = dragDistance; } else { d->tabList[d->pressedIndex].dragOffset = 0; } QRect startingRect = tabRect(d->pressedIndex); if (vertical) startingRect.moveTop(startingRect.y() + dragDistance); else startingRect.moveLeft(startingRect.x() + dragDistance); int overIndex; if (dragDistance < 0) overIndex = tabAt(startingRect.topLeft()); else overIndex = tabAt(startingRect.topRight()); if (overIndex != d->pressedIndex && overIndex != -1) { int offset = 1; if (isRightToLeft() && !vertical) offset *= -1; if (dragDistance < 0) { dragDistance *= -1; offset *= -1; } for (int i = d->pressedIndex; offset > 0 ? i < overIndex : i > overIndex; i += offset) { QRect overIndexRect = tabRect(overIndex); int needsToBeOver = (vertical ? overIndexRect.height() : overIndexRect.width()) / 2; if (dragDistance > needsToBeOver) { slide(i + offset, d->pressedIndex); } } } // Buttons needs to follow the dragged tab layoutTab(d->pressedIndex); update(); } void DTabBarPrivate::setupDragableTab() { if (!dragable) return; D_Q(DTabBar); QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); QStyleOptionTab opt; initStyleOption(&opt, d->pressedIndex); QMimeData *mime_data = q->createMimeDataFromTab(d->pressedIndex, opt); if (!mime_data) return; if (drag) drag->deleteLater(); drag = new QDrag(this); QPoint hotspot = drag->hotSpot(); const QPixmap &grabImage = q->createDragPixmapFromTab(d->pressedIndex, opt, &hotspot); drag->setPixmap(grabImage); drag->setMimeData(mime_data); drag->setHotSpot(hotspot); QMetaObject::invokeMethod(this, "startDrag", Qt::QueuedConnection, Q_ARG(int, d->pressedIndex)); } void DTabBarPrivate::slide(int from, int to) { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); if (from == to || !d->validIndex(from) || !d->validIndex(to)) return; bool vertical = verticalTabs(d->shape); int preLocation = vertical ? tabRect(from).y() : tabRect(from).x(); setUpdatesEnabled(false); moveTab(from, to); setUpdatesEnabled(true); int postLocation = vertical ? tabRect(to).y() : tabRect(to).x(); int length = postLocation - preLocation; d->tabList[to].dragOffset -= length; if (!d->isAnimated()) { moveTabFinished(to); return; } QTabBarPrivate::Tab *tab = &d->tabList[to]; if (!tab->animation) tab->animation = reinterpret_cast(new TabBarAnimation(tab, d, this)); tab->animation->setStartValue(tab->dragOffset); tab->animation->setEndValue(0); tab->animation->setEasingCurve(QEasingCurve::OutCubic); tab->animation->setDuration(ANIMATION_DURATION); tab->animation->start(); } void DTabBarPrivate::layoutTab(int index) { Q_ASSERT(index >= 0); QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); QTabBarPrivate::Tab &tab = d->tabList[index]; bool vertical = verticalTabs(d->shape); if (!(tab.leftWidget || tab.rightWidget)) return; QStyleOptionTab opt; initStyleOption(&opt, index); if (tab.leftWidget) { QRect rect = style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, this); QPoint p = rect.topLeft(); if ((index == d->pressedIndex) || d->paintWithOffsets) { if (vertical) p.setY(p.y() + d->tabList[index].dragOffset); else p.setX(p.x() + d->tabList[index].dragOffset); } tab.leftWidget->move(p); } if (tab.rightWidget) { QRect rect = style()->subElementRect(QStyle::SE_TabBarTabRightButton, &opt, this); QPoint p = rect.topLeft(); if ((index == d->pressedIndex) || d->paintWithOffsets) { if (vertical) p.setY(p.y() + tab.dragOffset); else p.setX(p.x() + tab.dragOffset); } tab.rightWidget->move(p); } } void DTabBarPrivate::moveTabFinished(int index) { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); bool cleanup = (d->pressedIndex == index) || (d->pressedIndex == -1) || !d->validIndex(index); bool allAnimationsFinished = true; #ifndef QT_NO_ANIMATION for(int i = 0; allAnimationsFinished && i < d->tabList.count(); ++i) { const QTabBarPrivate::Tab &t = d->tabList.at(i); if (t.animation && t.animation->state() == QAbstractAnimation::Running) allAnimationsFinished = false; } #endif //QT_NO_ANIMATION if (allAnimationsFinished && cleanup) { if(d->movingTab) d->movingTab->setVisible(false); // We might not get a mouse release for (int i = 0; i < d->tabList.count(); ++i) { d->tabList[i].dragOffset = 0; } if (d->pressedIndex != -1 && d->movable) { d->pressedIndex = -1; d->dragInProgress = false; d->dragStartPosition = QPoint(); } layoutWidgets(); } else { if (!d->validIndex(index)) return; d->tabList[index].dragOffset = 0; } update(); } void DTabBarPrivate::layoutWidgets(int start) { for (int i = start; i < count(); ++i) { layoutTab(i); } } void DTabBarPrivate::makeVisible(int index) { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); if (!d->validIndex(index)) return; const QRect tabRect = d->tabList.at(index).rect; const int oldScrollOffset = d->scrollOffset; const bool horiz = !verticalTabs(d->shape); const int extra_width = 2 * qMax(style()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, 0, this), QApplication::globalStrut().width()); const int available = (horiz ? width() : height()) - extra_width; const int start = horiz ? tabRect.left() : tabRect.top(); const int end = horiz ? tabRect.right() : tabRect.bottom(); if (start < d->scrollOffset) // too far left d->scrollOffset = start - (index ? 8 : 0); else if (end > d->scrollOffset + available) // too far right d->scrollOffset = end - available + 1; d->leftB->setEnabled(d->scrollOffset > 0); const int last = horiz ? d->tabList.last().rect.right() : d->tabList.last().rect.bottom(); d->rightB->setEnabled(last - d->scrollOffset >= available); if (oldScrollOffset != d->scrollOffset) { layoutWidgets(); } } void DTabBarPrivate::autoScrollTabs(const QPoint &mouse) { const QRect &rect = this->rect(); if (!rect.contains(mouse)) { return stopAutoScrollTabs(); } QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); bool vertical = verticalTabs(d->shape); const QSize &size_hint = this->sizeHint(); int scroll_distance = qMin(50, vertical ? rect.height() / 3 : rect.width() / 3); int start = 0; int end = 0; int scroll_end = 0; int scroll_speed = 0; if (vertical) { end = size_hint.height() - rect.height(); if (mouse.y() < scroll_distance) { if (d->scrollOffset <= start) return; // to up scroll_end = start; scroll_speed = mouse.y(); } else if (mouse.y() > rect.height() - scroll_distance) { if (d->scrollOffset >= end) return; // to down scroll_end = end; scroll_speed = rect.height() - mouse.y(); } else { return stopAutoScrollTabs(); } } else { end = size_hint.width() - rect.width(); if (mouse.x() < scroll_distance) { if (d->scrollOffset <= start) return; // to left scroll_end = start; scroll_speed = mouse.x(); } else if (mouse.x() > rect.width() - scroll_distance) { if (d->scrollOffset >= end) return; // to right scroll_end = end; scroll_speed = rect.width() - mouse.x(); } else { return stopAutoScrollTabs(); } } ensureScrollTabsAnimation(); if (scrollTabAnimation->state() == QVariantAnimation::Running) scrollTabAnimation->stop(); scrollTabAnimation->setDuration(qreal(qMax(qAbs(scroll_speed), 10)) / scroll_distance * (qAbs(scroll_end - d->scrollOffset) / 150) * 1000); scrollTabAnimation->setStartValue(d->scrollOffset); scrollTabAnimation->setEndValue(scroll_end); scrollTabAnimation->start(); } void DTabBarPrivate::stopAutoScrollTabs() { if (!scrollTabAnimation) return; scrollTabAnimation->stop(); scrollTabAnimation->deleteLater(); scrollTabAnimation = nullptr; } void DTabBarPrivate::ensureScrollTabsAnimation() { if (scrollTabAnimation) { return; } scrollTabAnimation = new QVariantAnimation(this); connect(scrollTabAnimation, &QVariantAnimation::valueChanged, this, [this] (const QVariant &value) { if (scrollTabAnimation->state() != QVariantAnimation::Running) return; bool ok = false; int v = value.toInt(&ok); if (!ok) return; QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); d->scrollOffset = v; if (d->dragInProgress && d->validIndex(d->pressedIndex)) { if (verticalTabs(d->shape)) { d->dragStartPosition.setY(dragStartPosition.y() + scrollOffset - v); } else { d->dragStartPosition.setX(dragStartPosition.x() + scrollOffset - v); } const QPoint bak_dragStartPosition = d->dragStartPosition; updateMoveingTabPosition(mapFromGlobal(QCursor::pos())); if (bak_dragStartPosition != d->dragStartPosition) { dragStartPosition = d->dragStartPosition; scrollOffset = d->scrollOffset; } } else { layoutWidgets(); update(); } }); connect(scrollTabAnimation, &QVariantAnimation::finished, this, [this] { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); d->leftB->setEnabled(d->scrollOffset > 0); d->rightB->setEnabled(d->scrollOffset < sizeHint().width() - width()); }); } void DTabBarPrivate::updateTabSize() { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); bool is_vertical = verticalTabs(d->shape); for (int i = 0; i < d->tabList.count(); ++i) { QTabBarPrivate::Tab &tab = d->tabList[i]; const QSize &size_hint = tabSizeHint(i); const QSize old_size = tab.rect.size(); if (is_vertical) { tab.rect.setWidth(qMax(size_hint.width(), width())); } else { tab.rect.setHeight(qMax(size_hint.height(), height())); } if (tab.rect.size() != old_size) layoutTab(i); } } void DTabBarPrivate::startTabFlash() { QVariantAnimation *animation = new QVariantAnimation(this); animation->setStartValue(1.0); animation->setEndValue(0.0); animation->setDuration(500); animation->setLoopCount(3); connect(animation, &QVariantAnimation::valueChanged, this, [this] (const QVariant &v) { opacityOnFlash = v.toReal(); update(); }); connect(animation, &QVariantAnimation::finished, this, [this, animation] { animation->deleteLater(); flashTabIndex = -1; }); connect(animation, &QVariantAnimation::currentLoopChanged, this, [animation] (int loop) { if (loop % 2) { animation->setStartValue(1.0); animation->setEndValue(0.0); } else { animation->setStartValue(0.0); animation->setEndValue(1.0); } }); animation->start(); } void DTabBarPrivate::setDragingFromOther(bool v) { if (v == dragingFromOther) return; dragingFromOther = v; if (!v) { if (topFullWidget) { topFullWidget->hide(); topFullWidget->deleteLater(); topFullWidget = nullptr; } return; } D_Q(DTabBar); if (!topFullWidget) topFullWidget = new FullWidget(q); topFullWidget->color = maskColor; topFullWidget->resize(q->size()); topFullWidget->show(); topFullWidget->raise(); } int DTabBarPrivate::tabInsertIndexFromMouse(const QPoint &pos) { int current = tabAt(pos); QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); bool vertical = verticalTabs(this->shape()); if (!d->validIndex(current)){ if (vertical) current = pos.y() >= height() ? -1 : 0; else current = pos.x() >= width() ? -1 : 0; } const QRect ¤t_rect = tabRect(current); const QPoint ¢er = current_rect.center(); if (vertical) { return pos.y() <= center.y() ? current : current + 1; } else { return pos.x() <= center.x() ? current : current + 1; } } bool DTabBarPrivate::eventFilter(QObject *watched, QEvent *event) { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); if (watched == d->leftB) { switch (event->type()) { case QEvent::Show: leftScrollButton->show(); break; case QEvent::Hide: leftScrollButton->hide(); break; case QEvent::EnabledChange: leftScrollButton->setEnabled(d->leftB->isEnabled()); break; case QEvent::UpdateRequest: leftScrollButton->setArrowType(d->leftB->arrowType()); break; default: break; } } else if (watched == d->rightB) { switch (event->type()) { case QEvent::Show: rightScrollButton->show(); break; case QEvent::Hide: rightScrollButton->hide(); break; case QEvent::EnabledChange: rightScrollButton->setEnabled(d->rightB->isEnabled()); break; case QEvent::UpdateRequest: rightScrollButton->setArrowType(d->rightB->arrowType()); break; default: break; } } return QTabBar::eventFilter(watched, event); } QSize DTabBarPrivate::minimumSizeHint() const { const QSize &hint = sizeHint(); QSize size = QTabBar::minimumSizeHint(); size.setWidth(qMin(size.width(), hint.width())); size.setHeight(qMin(size.height(), hint.height())); return size; } void DTabBarPrivate::paintEvent(QPaintEvent *e) { Q_UNUSED(e) D_Q(DTabBar); QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); QStyleOptionTabBarBase optTabBase; QTabBarPrivate::initStyleBaseOption(&optTabBase, this, size()); QStylePainter p(this); int selected = -1; // int cut = -1; // bool rtl = optTabBase.direction == Qt::RightToLeft; bool vertical = verticalTabs(d->shape); // QStyleOptionTab cutTab; selected = d->currentIndex; if (d->dragInProgress) selected = d->pressedIndex; for (int i = 0; i < d->tabList.count(); ++i) optTabBase.tabBarRect |= tabRect(i); optTabBase.selectedTabRect = tabRect(selected); if (d->drawBase) p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase); for (int i = 0; i < d->tabList.count(); ++i) { QStyleOptionTab tab; initStyleOption(&tab, i); // 强制让文本居中 tab.rightButtonSize = QSize(); if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) { if (vertical) { tab.rect.moveTop(tab.rect.y() + d->tabList[i].dragOffset); } else { tab.rect.moveLeft(tab.rect.x() + d->tabList[i].dragOffset); } } if (!(tab.state & QStyle::State_Enabled)) { tab.palette.setCurrentColorGroup(QPalette::Disabled); } // If this tab is partially obscured, make a note of it so that we can pass the information // along when we draw the tear. // if (((!vertical && (!rtl && tab.rect.left() < 0)) || (rtl && tab.rect.right() > width())) // || (vertical && tab.rect.top() < 0)) { // cut = i; // cutTab = tab; // } // Don't bother drawing a tab if the entire tab is outside of the visible tab bar. if ((!vertical && (tab.rect.right() < 0 || tab.rect.left() > width())) || (vertical && (tab.rect.bottom() < 0 || tab.rect.top() > height()))) continue; optTabBase.tabBarRect |= tab.rect; if (i == selected) continue; q->paintTab(&p, i, tab); if (i == flashTabIndex) { p.setOpacity(opacityOnFlash); p.fillRect(tab.rect, flashColor); p.setOpacity(1); } } // Draw the selected tab last to get it "on top" if (selected >= 0) { QStyleOptionTab tab; initStyleOption(&tab, selected); // 强制让文本居中 tab.rightButtonSize = QSize(); if (d->paintWithOffsets && d->tabList[selected].dragOffset != 0) { if (vertical) { tab.rect.moveTop(tab.rect.y() + d->tabList[selected].dragOffset); } else { tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset); } } if (!d->dragInProgress) { q->paintTab(&p, selected, tab); if (selected == flashTabIndex) { p.setOpacity(opacityOnFlash); p.fillRect(tab.rect, flashColor); p.setOpacity(1); } } else { int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); } } // Only draw the tear indicator if necessary. Most of the time we don't need too. // if (d->leftB->isVisible() && cut >= 0) { // cutTab.rect = rect(); // cutTab.rect = style()->subElementRect(QStyle::SE_TabBarTearIndicator, &cutTab, this); // p.drawPrimitive(QStyle::PE_IndicatorTabTear, cutTab); // } } void DTabBarPrivate::mouseMoveEvent(QMouseEvent *event) { QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); if (!d->movable) return; // Be safe! if (d->pressedIndex != -1 && event->buttons() == Qt::NoButton) moveTabFinished(d->pressedIndex); int offset_x = qAbs(event->x() - d->dragStartPosition.x()); int offset_y = qAbs(event->y() - d->dragStartPosition.y()); bool valid_pressed_index = d->validIndex(d->pressedIndex); if (verticalTabs(d->shape)) { std::swap(offset_x, offset_y); } // Start drag if (drag && drag->property("_d_DTabBarPrivate_drity").toBool()) { drag->deleteLater(); } if (!drag && valid_pressed_index) { if (offset_y > startDragDistance) { setupDragableTab(); } } // Start move if (!d->dragInProgress && valid_pressed_index) { if (offset_x > startDragDistance) { d->dragInProgress = true; setupMovableTab(); scrollOffset = d->scrollOffset; dragStartPosition = d->dragStartPosition; } } if (event->buttons() == Qt::LeftButton && offset_x > startDragDistance && valid_pressed_index) { updateMoveingTabPosition(event->pos()); scrollOffset = d->scrollOffset; dragStartPosition = d->dragStartPosition; // Auto scroll tags autoScrollTabs(event->pos()); } } void DTabBarPrivate::mouseReleaseEvent(QMouseEvent *e) { QTabBar::mouseReleaseEvent(e); stopAutoScrollTabs(); } void DTabBarPrivate::dragEnterEvent(QDragEnterEvent *e) { if (e->source() == this) { e->acceptProposedAction(); QMouseEvent event(QEvent::MouseMove, e->posF(), Qt::LeftButton, e->mouseButtons(), e->keyboardModifiers()); mouseMoveEvent(&event); } else { int index = tabInsertIndexFromMouse(e->pos()); if (q_func()->canInsertFromMimeData(index, e->mimeData())) { setDragingFromOther(true); e->acceptProposedAction(); } } } void DTabBarPrivate::dragLeaveEvent(QDragLeaveEvent *e) { setDragingFromOther(false); stopAutoScrollTabs(); QTabBar::dragLeaveEvent(e); QTabBarPrivate *d = reinterpret_cast(qGetPtrHelper(d_ptr)); // clean hover state d->hoverRect = QRect(); } void DTabBarPrivate::dragMoveEvent(QDragMoveEvent *e) { if (e->source() == this) { e->acceptProposedAction(); QMouseEvent event(QEvent::MouseMove, e->posF(), Qt::LeftButton, e->mouseButtons(), e->keyboardModifiers()); mouseMoveEvent(&event); } else { autoScrollTabs(e->pos()); int index = tabInsertIndexFromMouse(e->pos()); if (q_func()->canInsertFromMimeData(index, e->mimeData())) { setDragingFromOther(true); e->acceptProposedAction(); } } } void DTabBarPrivate::dropEvent(QDropEvent *e) { if (e->source() == this) { e->acceptProposedAction(); QMouseEvent event(QEvent::MouseButtonRelease, e->posF(), Qt::LeftButton, e->mouseButtons(), e->keyboardModifiers()); mouseReleaseEvent(&event); } else { setDragingFromOther(false); int index = tabInsertIndexFromMouse(e->pos()); if (q_func()->canInsertFromMimeData(index, e->mimeData())) { e->acceptProposedAction(); e->setDropAction(Qt::MoveAction); q_func()->insertFromMimeData(index, e->mimeData()); } } stopAutoScrollTabs(); } void DTabBarPrivate::showEvent(QShowEvent *e) { updateGeometry(); QTabBar::showEvent(e); } void DTabBarPrivate::resizeEvent(QResizeEvent *e) { updateTabSize(); QTabBar::resizeEvent(e); } QSize DTabBarPrivate::tabSizeHint(int index) const { D_QC(DTabBar); QSize size = QTabBar::tabSizeHint(index); if (index >= tabMaximumSize.count()) return size; const QSize &min = tabMinimumSize.at(index); const QSize &max = tabMaximumSize.at(index); size.setWidth(qMax(size.width(), min.width())); size.setHeight(qMax(size.height(), min.height())); if (max.isValid()) { size.setWidth(qMin(size.width(), max.width())); size.setHeight(qMin(size.height(), max.height())); } return size; } QSize DTabBarPrivate::minimumTabSizeHint(int index) const { const QSize &min = tabMinimumSize.value(index); if (min.isValid()) return min; return QTabBar::minimumTabSizeHint(index); } QSize DTabBarPrivate::maximumTabSizeHint(int index) const { const QSize &max = tabMaximumSize.value(index); if (max.isValid()) return max; return QTabBar::tabSizeHint(index); } void DTabBarPrivate::tabInserted(int index) { tabMaximumSize.insert(index, QSize()); tabMinimumSize.insert(index, QSize()); QTabBar::tabInserted(index); } void DTabBarPrivate::tabRemoved(int index) { tabMaximumSize.removeAt(index); tabMinimumSize.removeAt(index); QTabBar::tabInserted(index); } void DTabBarPrivate::tabLayoutChange() { updateTabSize(); QTabBar::tabLayoutChange(); } void DTabBarPrivate::initStyleOption(QStyleOptionTab *option, int tabIndex) const { QTabBar::initStyleOption(option, tabIndex); } DTabBar::DTabBar(QWidget *parent) : QWidget(parent) , DObject(*new DTabBarPrivate(this)) { setAcceptDrops(true); } void DTabBar::setTabMinimumSize(int index, const QSize &size) { D_D(DTabBar); d->tabMinimumSize[index] = size; } void DTabBar::setTabMaximumSize(int index, const QSize &size) { D_D(DTabBar); d->tabMaximumSize[index] = size; } bool DTabBar::visibleAddButton() const { D_DC(DTabBar); return d->visibleAddButton; } QTabBar::Shape DTabBar::shape() const { return d_func()->shape(); } void DTabBar::setShape(QTabBar::Shape shape) { D_D(DTabBar); bool old_vertical = verticalTabs(d_func()->shape()); bool new_vertical = verticalTabs(shape); d->setShape(shape); if (old_vertical != new_vertical) { if (QBoxLayout *layout = qobject_cast(this->layout())) { if (new_vertical) layout->setDirection(QBoxLayout::TopToBottom); else layout->setDirection(QBoxLayout::LeftToRight); } if (new_vertical) { d->leftScrollButton->setArrowType(Qt::UpArrow); d->rightScrollButton->setArrowType(Qt::DownArrow); d->leftScrollButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); d->rightScrollButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); d->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); d->addButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); d->addButton->setFixedHeight(48); d->addButton->setMinimumWidth(0); d->addButton->setMaximumWidth(9999); } else { d->leftScrollButton->setArrowType(Qt::LeftArrow); d->rightScrollButton->setArrowType(Qt::RightArrow); d->leftScrollButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); d->rightScrollButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); d->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding); d->addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); d->addButton->setFixedWidth(48); d->addButton->setMinimumHeight(0); d->addButton->setMaximumHeight(9999); } } } int DTabBar::addTab(const QString &text) { return d_func()->addTab(text); } int DTabBar::addTab(const QIcon &icon, const QString &text) { return d_func()->addTab(icon, text); } int DTabBar::insertTab(int index, const QString &text) { return d_func()->insertTab(index, text); } int DTabBar::insertTab(int index, const QIcon &icon, const QString &text) { return insertTab(index, icon, text); } void DTabBar::removeTab(int index) { d_func()->removeTab(index); } void DTabBar::moveTab(int from, int to) { d_func()->moveTab(from, to); } bool DTabBar::isTabEnabled(int index) const { return d_func()->isTabEnabled(index); } void DTabBar::setTabEnabled(int index, bool enable) { d_func()->setTabEnabled(index, enable); } QString DTabBar::tabText(int index) const { return d_func()->tabText(index); } void DTabBar::setTabText(int index, const QString &text) { d_func()->setTabText(index, text); } QIcon DTabBar::tabIcon(int index) const { return d_func()->tabIcon(index); } void DTabBar::setTabIcon(int index, const QIcon &icon) { d_func()->setTabIcon(index, icon); } Qt::TextElideMode DTabBar::elideMode() const { return d_func()->elideMode(); } void DTabBar::setElideMode(Qt::TextElideMode mode) { d_func()->setElideMode(mode); } #ifndef QT_NO_TOOLTIP void DTabBar::setTabToolTip(int index, const QString &tip) { d_func()->setTabToolTip(index, tip); } QString DTabBar::tabToolTip(int index) const { return d_func()->tabToolTip(index); } #endif #ifndef QT_NO_WHATSTHIS void DTabBar::setTabWhatsThis(int index, const QString &text) { d_func()->setTabWhatsThis(index, text); } QString DTabBar::tabWhatsThis(int index) const { return d_func()->tabWhatsThis(index); } #endif void DTabBar::setTabData(int index, const QVariant &data) { d_func()->setTabData(index, data); } QVariant DTabBar::tabData(int index) const { return d_func()->tabData(index); } QRect DTabBar::tabRect(int index) const { QRect rect = d_func()->tabRect(index); rect.moveTopLeft(d_func()->mapToParent(rect.topLeft())); return rect; } int DTabBar::tabAt(const QPoint &pos) const { return d_func()->tabAt(d_func()->mapFromParent(pos)); } int DTabBar::currentIndex() const { return d_func()->currentIndex(); } int DTabBar::count() const { return d_func()->count(); } void DTabBar::setDrawBase(bool drawTheBase) { d_func()->setDrawBase(drawTheBase); } bool DTabBar::drawBase() const { return d_func()->drawBase(); } QSize DTabBar::iconSize() const { return d_func()->iconSize(); } void DTabBar::setIconSize(const QSize &size) { d_func()->setIconSize(size); } bool DTabBar::usesScrollButtons() const { return d_func()->usesScrollButtons(); } void DTabBar::setUsesScrollButtons(bool useButtons) { d_func()->setUsesScrollButtons(useButtons); } bool DTabBar::tabsClosable() const { return d_func()->tabsClosable(); } void DTabBar::setTabsClosable(bool closable) { d_func()->setTabsClosable(closable); } void DTabBar::setTabButton(int index, QTabBar::ButtonPosition position, QWidget *widget) { d_func()->setTabButton(index, position, widget); } QWidget *DTabBar::tabButton(int index, QTabBar::ButtonPosition position) const { return d_func()->tabButton(index, position); } QTabBar::SelectionBehavior DTabBar::selectionBehaviorOnRemove() const { return d_func()->selectionBehaviorOnRemove(); } void DTabBar::setSelectionBehaviorOnRemove(QTabBar::SelectionBehavior behavior) { d_func()->setSelectionBehaviorOnRemove(behavior); } bool DTabBar::expanding() const { return d_func()->expanding(); } void DTabBar::setExpanding(bool enabled) { d_func()->setExpanding(enabled); } bool DTabBar::isMovable() const { return d_func()->isMovable(); } void DTabBar::setMovable(bool movable) { d_func()->setMovable(movable); } bool DTabBar::isDragable() const { return d_func()->dragable; } void DTabBar::setDragable(bool dragable) { d_func()->dragable = dragable; } bool DTabBar::documentMode() const { return d_func()->documentMode(); } void DTabBar::setDocumentMode(bool set) { d_func()->setDocumentMode(set); } bool DTabBar::autoHide() const { return d_func()->autoHide(); } void DTabBar::setAutoHide(bool hide) { d_func()->setAutoHide(hide); } bool DTabBar::changeCurrentOnDrag() const { return d_func()->changeCurrentOnDrag(); } void DTabBar::setChangeCurrentOnDrag(bool change) { d_func()->setChangeCurrentOnDrag(change); } int DTabBar::startDragDistance() const { return d_func()->startDragDistance; } QColor DTabBar::maskColor() const { return d_func()->maskColor; } QColor DTabBar::flashColor() const { return d_func()->flashColor; } void DTabBar::setCurrentIndex(int index) { d_func()->setCurrentIndex(index); } void DTabBar::setVisibleAddButton(bool visibleAddButton) { D_D(DTabBar); d->visibleAddButton = visibleAddButton; d->addButton->setVisible(visibleAddButton); } void DTabBar::setStartDragDistance(int startDragDistance) { d_func()->startDragDistance = startDragDistance; } void DTabBar::setMaskColor(QColor maskColor) { d_func()->maskColor = maskColor; } void DTabBar::setFlashColor(QColor flashColor) { d_func()->flashColor = flashColor; } void DTabBar::dragEnterEvent(QDragEnterEvent *e) { D_D(DTabBar); if (e->source() == d) return QWidget::dragEnterEvent(e); int index = d->tabInsertIndexFromMouse(d->mapFromParent(e->pos())); if (canInsertFromMimeData(index, e->mimeData())) { d->setDragingFromOther(true); e->acceptProposedAction(); } } void DTabBar::dragLeaveEvent(QDragLeaveEvent *e) { Q_UNUSED(e) D_D(DTabBar); d->setDragingFromOther(false); d->stopAutoScrollTabs(); } void DTabBar::dragMoveEvent(QDragMoveEvent *e) { D_D(DTabBar); if (e->source() == d) return QWidget::dragMoveEvent(e); if (e->source() != d) d->autoScrollTabs(d->mapFromParent(e->pos())); int index = d->tabInsertIndexFromMouse(d->mapFromParent(e->pos())); if (canInsertFromMimeData(index, e->mimeData())) { d->setDragingFromOther(true); e->acceptProposedAction(); } } void DTabBar::dropEvent(QDropEvent *e) { D_D(DTabBar); if (e->source() == d) return QWidget::dropEvent(e); d->setDragingFromOther(false); d->stopAutoScrollTabs(); int index = d->tabInsertIndexFromMouse(d->mapFromParent(e->pos())); if (canInsertFromMimeData(index, e->mimeData())) { e->acceptProposedAction(); e->setDropAction(Qt::MoveAction); insertFromMimeData(index, e->mimeData()); } } void DTabBar::resizeEvent(QResizeEvent *e) { D_D(DTabBar); if (d->topFullWidget) { d->topFullWidget->resize(e->size()); d->topFullWidget->raise(); } return QWidget::resizeEvent(e); } void DTabBar::paintTab(QPainter *painter, int index, const QStyleOptionTab &option) const { Q_UNUSED(index) style()->drawControl(QStyle::CE_TabBarTab, &option, painter, this); } QPixmap DTabBar::createDragPixmapFromTab(int index, const QStyleOptionTab &option, QPoint *hotspot) const { Q_UNUSED(hotspot) QPixmap grabImage(option.rect.size() * devicePixelRatioF()); grabImage.setDevicePixelRatio(devicePixelRatioF()); grabImage.fill(Qt::transparent); QStyleOptionTab tab = option; int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); tab.rect.moveTopLeft(QPoint(taboverlap, 0)); QPainter p(&grabImage); p.initFrom(d_func()); paintTab(&p, index, tab); return grabImage; } QMimeData *DTabBar::createMimeDataFromTab(int index, const QStyleOptionTab &option) const { Q_UNUSED(index) Q_UNUSED(option) QMimeData *data = new QMimeData(); data->setText(tabText(index)); data->setData("deepin/dtkwidget-DTabBar-tab", QByteArray()); return data; } bool DTabBar::canInsertFromMimeData(int index, const QMimeData *source) const { Q_UNUSED(index) return source->hasFormat("deepin/dtkwidget-DTabBar-tab"); } void DTabBar::insertFromMimeData(int index, const QMimeData *source) { d_func()->flashTabIndex = insertTab(index, source->text()); d_func()->makeVisible(d_func()->flashTabIndex); d_func()->startTabFlash(); } DTabBarPrivate *DTabBar::d_func() { return dynamic_cast(d_d_ptr.data()); } const DTabBarPrivate *DTabBar::d_func() const { return dynamic_cast(d_d_ptr.data()); } DWIDGET_END_NAMESPACE #include "dtabbar.moc" dtkwidget-2.0.7.2/src/widgets/dtabbar.h000066400000000000000000000146131325435343100176630ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: zccrs * * Maintainer: zccrs * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTABBAR_H #define DTABBAR_H #include #include #include QT_BEGIN_NAMESPACE class QMimeData; QT_END_NAMESPACE DCORE_USE_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DTabBarPrivate; class DTabBar : public QWidget, public DObject { Q_OBJECT Q_PROPERTY(bool visibleAddButton READ visibleAddButton WRITE setVisibleAddButton) Q_PROPERTY(QTabBar::Shape shape READ shape WRITE setShape) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged) Q_PROPERTY(int count READ count) Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase) Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode) Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons) Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable) Q_PROPERTY(QTabBar::SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove WRITE setSelectionBehaviorOnRemove) Q_PROPERTY(bool expanding READ expanding WRITE setExpanding) Q_PROPERTY(bool movable READ isMovable WRITE setMovable) Q_PROPERTY(bool dragable READ isDragable WRITE setDragable) Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode) Q_PROPERTY(bool autoHide READ autoHide WRITE setAutoHide) Q_PROPERTY(bool changeCurrentOnDrag READ changeCurrentOnDrag WRITE setChangeCurrentOnDrag) Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance) // on drag enter Q_PROPERTY(QColor maskColor READ maskColor WRITE setMaskColor) // on inserted tab from mime data Q_PROPERTY(QColor flashColor READ flashColor WRITE setFlashColor) public: explicit DTabBar(QWidget *parent = 0); void setTabMinimumSize(int index, const QSize &size); void setTabMaximumSize(int index, const QSize &size); bool visibleAddButton() const; QTabBar::Shape shape() const; void setShape(QTabBar::Shape shape); int addTab(const QString &text); int addTab(const QIcon &icon, const QString &text); int insertTab(int index, const QString &text); int insertTab(int index, const QIcon&icon, const QString &text); void removeTab(int index); void moveTab(int from, int to); bool isTabEnabled(int index) const; void setTabEnabled(int index, bool); QString tabText(int index) const; void setTabText(int index, const QString &text); QIcon tabIcon(int index) const; void setTabIcon(int index, const QIcon &icon); Qt::TextElideMode elideMode() const; void setElideMode(Qt::TextElideMode mode); #ifndef QT_NO_TOOLTIP void setTabToolTip(int index, const QString &tip); QString tabToolTip(int index) const; #endif #ifndef QT_NO_WHATSTHIS void setTabWhatsThis(int index, const QString &text); QString tabWhatsThis(int index) const; #endif void setTabData(int index, const QVariant &data); QVariant tabData(int index) const; QRect tabRect(int index) const; int tabAt(const QPoint &pos) const; int currentIndex() const; int count() const; void setDrawBase(bool drawTheBase); bool drawBase() const; QSize iconSize() const; void setIconSize(const QSize &size); bool usesScrollButtons() const; void setUsesScrollButtons(bool useButtons); bool tabsClosable() const; void setTabsClosable(bool closable); void setTabButton(int index, QTabBar::ButtonPosition position, QWidget *widget); QWidget *tabButton(int index, QTabBar::ButtonPosition position) const; QTabBar::SelectionBehavior selectionBehaviorOnRemove() const; void setSelectionBehaviorOnRemove(QTabBar::SelectionBehavior behavior); bool expanding() const; void setExpanding(bool enabled); bool isMovable() const; void setMovable(bool movable); bool isDragable() const; void setDragable(bool dragable); bool documentMode() const; void setDocumentMode(bool set); bool autoHide() const; void setAutoHide(bool hide); bool changeCurrentOnDrag() const; void setChangeCurrentOnDrag(bool change); int startDragDistance() const; QColor maskColor() const; QColor flashColor() const; Q_SIGNALS: void currentChanged(int index); void tabCloseRequested(int index); void tabMoved(int from, int to); void tabBarClicked(int index); void tabBarDoubleClicked(int index); void tabAddRequested(); void tabReleaseRequested(int index); void tabDroped(int index, Qt::DropAction action, QObject *target); public Q_SLOTS: void setCurrentIndex(int index); void setVisibleAddButton(bool visibleAddButton); void setStartDragDistance(int startDragDistance); void setMaskColor(QColor maskColor); void setFlashColor(QColor flashColor); protected: void dragEnterEvent(QDragEnterEvent *e) override; void dragLeaveEvent(QDragLeaveEvent *e) override; void dragMoveEvent(QDragMoveEvent *e) override; void dropEvent(QDropEvent *e) override; void resizeEvent(QResizeEvent *e) override; virtual void paintTab(QPainter *painter, int index, const QStyleOptionTab &option) const; virtual QPixmap createDragPixmapFromTab(int index, const QStyleOptionTab &option, QPoint *hotspot) const; virtual QMimeData *createMimeDataFromTab(int index, const QStyleOptionTab &option) const; virtual bool canInsertFromMimeData(int index, const QMimeData *source) const; virtual void insertFromMimeData(int index, const QMimeData *source); private: DTabBarPrivate* d_func(); const DTabBarPrivate* d_func() const; friend class DTabBarPrivate; }; DWIDGET_END_NAMESPACE #endif // DTABBAR_H dtkwidget-2.0.7.2/src/widgets/dtextbutton.cpp000066400000000000000000000017161325435343100212030ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dtextbutton.h" #include "dthememanager.h" DWIDGET_BEGIN_NAMESPACE DTextButton::DTextButton(const QString & text, QWidget * parent) : QPushButton(text, parent) { DThemeManager::registerWidget(this); } DTextButton::~DTextButton() { } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dtextbutton.h000066400000000000000000000020461325435343100206450ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTEXTBUTTON_H #define DTEXTBUTTON_H #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DTextButton : public QPushButton { Q_OBJECT public: DTextButton(const QString & text, QWidget * parent = 0); ~DTextButton(); }; DWIDGET_END_NAMESPACE #endif // DTEXTBUTTON_H dtkwidget-2.0.7.2/src/widgets/dtextedit.cpp000066400000000000000000000033531325435343100206140ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dtextedit.h" #include "dthememanager.h" #include "private/dtextedit_p.h" #include "dscrollbar.h" #include DWIDGET_BEGIN_NAMESPACE DTextEditPrivate::DTextEditPrivate(DTextEdit *qq) : DObjectPrivate(qq) { } void DTextEditPrivate::init() { D_Q(DTextEdit); insideFrame = new QFrame(q); insideFrame->setObjectName("TextEditInsideFrame"); insideFrame->setFocusProxy(q); insideFrame->setAttribute(Qt::WA_TransparentForMouseEvents); q->setContextMenuPolicy(Qt::NoContextMenu); q->setVerticalScrollBar(new DScrollBar); q->setHorizontalScrollBar(new DScrollBar); } DTextEdit::DTextEdit(QWidget *parent) : QTextEdit(parent), DObject(*new DTextEditPrivate(this)) { DThemeManager::registerWidget(this); d_func()->init(); } void DTextEdit::resizeEvent(QResizeEvent *event) { QTextEdit::resizeEvent(event); D_D(DTextEdit); const QSize &size = event->size(); d->insideFrame->setFixedHeight(size.height() - 1); d->insideFrame->setFixedWidth(size.width()); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dtextedit.h000066400000000000000000000022531325435343100202570ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTEXTEDIT_H #define DTEXTEDIT_H #include "dtkwidget_global.h" #include #include DWIDGET_BEGIN_NAMESPACE class DTextEditPrivate; class DTextEdit : public QTextEdit, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: explicit DTextEdit(QWidget *parent = 0); protected: void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DTextEdit) Q_DISABLE_COPY(DTextEdit) }; DWIDGET_END_NAMESPACE #endif // DTEXTEDIT_H dtkwidget-2.0.7.2/src/widgets/dthememanager.cpp000066400000000000000000000411251325435343100214160ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include "dthememanager.h" #include "dapplication.h" DWIDGET_BEGIN_NAMESPACE class DThemeManagerStaticPrivate : public DThemeManager { }; Q_GLOBAL_STATIC(DThemeManagerStaticPrivate, DThemeManagerStatic) /*! * \class DThemeManager * \brief The DThemeManager class provides helper to manage theme files of widgets. * * The DThemeManager is singleton class, DThemeManager::instance is used to * get an instance of DThemeManager. * * DThemeManager can be used to get the current application theme, find the * corresponding theme file of a widget. */ DThemeManager *DThemeManager::instance() { return DThemeManagerStatic; } static QString getObjectClassName(const QObject *obj) { const QString &type_name = QString::fromLocal8Bit(obj->metaObject()->className()); const QStringList &widget_type_list = type_name.split("::"); return widget_type_list.isEmpty() ? type_name : widget_type_list.last(); } // TODO: just for fix some bug, remove after 2.0.7 static QString getThemeNameByRawClassName(const QObject *obj) { return QString::fromLocal8Bit(obj->metaObject()->className()); } static QString getThemeNameByClassName(const QObject *obj) { QString type_name = QString::fromLocal8Bit(obj->metaObject()->className()); return type_name.replace("::", "--"); } static void emitThemeChanged(DThemeManager *manager, QWidget *widget, const QString &theme) { Q_EMIT manager->widgetThemeChanged(widget, theme); for (QObject *child : widget->children()) { if (QWidget *cw = qobject_cast(child)) { if (cw->property("_d_dtk_theme").isValid()) { continue; } emitThemeChanged(manager, cw, theme); } } } static void setStyle(QWidget *widget, QStyle *style) { widget->setStyle(style); for (QObject *child : widget->children()) { if (QWidget *cw = qobject_cast(child)) { if (cw->property("_d_dtk_theme").isValid()) { continue; } setStyle(cw, style); } } } static void inseritStyle(QWidget *widget, const QWidget *baseWidget) { if (widget == baseWidget) { return; } QStyle *base_style = baseWidget ? baseWidget->style() : qApp->style(); if (base_style->inherits("QStyleSheetStyle")) { base_style = static_cast(base_style)->base; } widget->setStyle(base_style); } static void updateWidgetTheme(DThemeManager *manager, QWidget *widget, QWidget *baseWidget, const QString &theme) { inseritStyle(widget, baseWidget); Q_EMIT manager->widgetThemeChanged(widget, theme); for (QObject *child : widget->children()) { if (QWidget *cw = qobject_cast(child)) { if (widget->property("_d_dtk_theme").isValid()) { return; } updateWidgetTheme(manager, cw, baseWidget, theme); } } } class DThemeManagerPrivate : public DCORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DThemeManager) QString themeName; QMap > watchedDynamicPropertys; public: DThemeManagerPrivate(DThemeManager *qq) : DObjectPrivate(qq) {} QString getQssContent(const QString &themeURL) const { QString qss; QFile themeFile(themeURL); if (themeFile.open(QIODevice::ReadOnly | QIODevice::Text)) { qss = themeFile.readAll(); themeFile.close(); } else { /// !!! if do not privode qss file, do not register it!!! qWarning() << "open qss file failed" << themeURL << themeFile.errorString(); } return qss; } bool themeFileExist(const QString &filename) const { QFileInfo fi(filename); return fi.exists(); } inline QString themeURL(const QString &themename, const QString &filename) const { if (themename.isEmpty() || filename.isEmpty()) { return ""; } return QString(":/%1/%2.theme").arg(themename).arg(filename); } QString fallbackWidgetThemeName(const QWidget *widget, QWidget **baseWidget = nullptr) const { QString theme; if (baseWidget) { *baseWidget = nullptr; } do { theme = widget->property("_d_dtk_theme").toString(); if (!theme.isEmpty()) { if (baseWidget) { *baseWidget = const_cast(widget); } break; } widget = widget->isWindow() ? 0 : widget->parentWidget(); } while (widget); return theme.isEmpty() ? themeName : theme; } QString fallbackWidgetThemeFilename(QWidget *w) const { QStringList fallbackList; QString overriveName = w->property("_d_dtk_theme_filename").toString(); if (!overriveName.isEmpty()) { fallbackList << overriveName; } QString className = getThemeNameByClassName(w); if (!className.isEmpty()) { fallbackList << className; } QString rawClassName = getThemeNameByRawClassName(w); if (!rawClassName.isEmpty()) { fallbackList << rawClassName; } auto themeName = fallbackWidgetThemeName(w, nullptr); for (auto filename : fallbackList) { if (themeFileExist(themeURL(themeName, filename))) { return filename; } } return ""; } void registerWidget(QWidget *widget, const QString &filename, const QStringList &propertys) { if (filename.isEmpty()) { qWarning() << "can not load qss with out filename" << widget; return; } auto themeurl = themeURL(fallbackWidgetThemeName(widget), filename); auto dtm = DThemeManager::instance(); widget->setStyleSheet(widget->styleSheet() + dtm->d_func()->getQssContent(themeurl)); auto reloadTheme = [this, dtm](QWidget * widget, const QString & filename, const QString & themename) { const char *baseClassReloadThemeProp = "_dtk_theme_base_calss_reload_theme"; auto themeurl = themeURL(fallbackWidgetThemeName(widget), filename); auto reloadTheme = widget->property(baseClassReloadThemeProp).toString(); if (reloadTheme != themename) { widget->setStyleSheet(dtm->d_func()->getQssContent(themeurl)); widget->setProperty(baseClassReloadThemeProp, themename); } else { widget->setStyleSheet(widget->styleSheet() + dtm->d_func()->getQssContent(themeurl)); } }; dtm->connect(dtm, &DThemeManager::themeChanged, widget, [reloadTheme, widget, filename](QString theme) { reloadTheme(widget, filename, theme); }); dtm->connect(dtm, &DThemeManager::widgetThemeChanged, widget, [reloadTheme, widget, filename](QWidget * w, QString theme) { if (widget == w) { reloadTheme(widget, filename, theme); } }); auto meta = widget->metaObject(); QMap dynamicPropertys; for (auto &prop : propertys) { auto propIndex = meta->indexOfProperty(prop.toLatin1().data()); if (propIndex < 0) { dynamicPropertys.insert(prop, prop); continue; } dtm->connect(widget, meta->property(propIndex).notifySignal(), dtm, dtm->metaObject()->method(dtm->metaObject()->indexOfMethod("updateQss()"))); } if (!dynamicPropertys.isEmpty()) { widget->installEventFilter(dtm); if (dtm->d_func()->watchedDynamicPropertys.contains(widget)) { QMap oldProps = dtm->d_func()->watchedDynamicPropertys.value(widget); for (auto &key : oldProps.keys()) { dynamicPropertys.insert(key, oldProps.value(key)); } } dtm->d_func()->watchedDynamicPropertys.insert(widget, dynamicPropertys); dtm->connect(widget, &QObject::destroyed, dtm, [ = ]() { dtm->d_func()->watchedDynamicPropertys.remove(widget); }); } } void setTheme(const QString theme) { D_Q(DThemeManager); if (themeName != theme) { QStyle *style = Q_NULLPTR; // TODO: remove this shit in the future. // It's just a trick to make all DApplications use dde qt5 styles, // if dlight or ddark style is set to default style of dde, those // ugly code will no longer needed. if (theme == "light") { style = QStyleFactory::create("dlight"); themeName = theme; } else if (theme == "dark") { style = QStyleFactory::create("ddark"); themeName = theme; } else if (theme == "semilight") { style = QStyleFactory::create("dsemilight"); themeName = "light"; } else if (theme == "semidark") { style = QStyleFactory::create("dsemidark"); themeName = "dark"; } if (style) { qApp->setStyle(style); } Q_EMIT q->themeChanged(themeName); } } void setTheme(QWidget *widget, const QString theme) { D_Q(DThemeManager); Q_ASSERT(widget); if (theme.isEmpty()) { QString old_theme = fallbackWidgetThemeName(widget); widget->setProperty("_d_dtk_theme", QVariant()); QWidget *baseWidget = nullptr; if (fallbackWidgetThemeName(widget, &baseWidget) != old_theme) { emitThemeChanged(q, widget, fallbackWidgetThemeName(widget)); } inseritStyle(widget, baseWidget); return; } const QString &old_theme = fallbackWidgetThemeName(widget); QStyle *style = Q_NULLPTR; // TODO: remove this shit in the future. // It's just a trick to make all DApplications use dde qt5 styles, // if dlight or ddark style is set to default style of dde, those // ugly code will no longer needed. if (theme == "light") { style = QStyleFactory::create("dlight"); widget->setProperty("_d_dtk_theme", theme); } else if (theme == "dark") { style = QStyleFactory::create("ddark"); widget->setProperty("_d_dtk_theme", theme); } else if (theme == "semilight") { style = QStyleFactory::create("dsemilight"); widget->setProperty("_d_dtk_theme", "light"); } else if (theme == "semidark") { style = QStyleFactory::create("dsemidark"); widget->setProperty("_d_dtk_theme", "dark"); } if (style) { setStyle(widget, style); } if (old_theme != theme) { emitThemeChanged(q, widget, theme); } } }; /*! * \brief DThemeManager::theme * \return the theme name currently be used by this application, the possible * value are "light" and "dark". */ QString DThemeManager::theme() const { D_DC(DThemeManager); return d->themeName; } QString DThemeManager::theme(const QWidget *widget, QWidget **baseWidget) const { D_DC(DThemeManager); return d->fallbackWidgetThemeName(widget, baseWidget); } /*! * \brief DThemeManager::setTheme sets the application theme. * \param theme is the theme name to be set. */ void DThemeManager::setTheme(const QString theme) { D_D(DThemeManager); d->setTheme(theme); } /*! * \brief DThemeManager::setTheme sets theme on a widget. * \param widget is the target widget. * \param theme is the name of theme to be set. */ void DThemeManager::setTheme(QWidget *widget, const QString theme) { D_D(DThemeManager); d->setTheme(widget, theme); } /*! * \brief DThemeManager::getQssForWidget searches for the theme file of one class in a specific theme. * \param className is the name of the class. * \param theme is the name of the theme to be applied. * \return The content of the theme file. * * \note The class name should have no namespace prefixes. */ QString DThemeManager::getQssForWidget(const QString className, const QString &theme) const { D_DC(DThemeManager); QString qss; QString themeName = theme.isEmpty() ? d->themeName : theme; QString themeURL = QString(":/%1/%2.theme").arg(themeName).arg(className); return d->getQssContent(themeURL); } /*! * \brief DThemeManager::getQssForWidget This function is overloaded. * \param className is the name of the target class. * \param widget is the widget from which to read the theme name. * \return The content of the theme file. * * \note The class name should have no namespace prefixes. */ QString DThemeManager::getQssForWidget(const QString className, const QWidget *widget) const { Q_ASSERT(widget); return getQssForWidget(className, theme(widget)); } /*! * \brief DThemeManager::getQssForWidget This function is overloaded. * \param widget is the target widget. * \return The content of the theme file to be applied on the widget. */ QString DThemeManager::getQssForWidget(const QWidget *widget) const { return getQssForWidget(getObjectClassName(widget), widget); } /*! \since 2.0 \relates DThemeManager Find QSS file on the qrc by getQssForWidget, className is form metaObject */ void DThemeManager::registerWidget(QWidget *widget, QStringList propertys) { auto dtm = DThemeManager::instance(); auto fileName = dtm->d_func()->fallbackWidgetThemeFilename(widget); registerWidget(widget, fileName, propertys); } /*! * \brief DThemeManager::registerWidget * \param widget * \param filename * \param propertys */ void DThemeManager::registerWidget(QWidget *widget, const QString &filename, const QStringList &propertys) { auto dtm = DThemeManager::instance(); dtm->d_func()->registerWidget(widget, filename, propertys); } /*! * \brief DThemeManager::updateQss This slot repolishes the theme applied on * the sender widget. * * This slot is triggered when the property of a registered widget changes, * it's useful because Qt has no support of repolishing the style if some * custom properties used in the QSS file has changed. */ void DThemeManager::updateQss() { QWidget *w = qobject_cast(sender()); if (w) { w->setStyleSheet(w->styleSheet()); } } DThemeManager::DThemeManager() : QObject() , DObject(*new DThemeManagerPrivate(this)) { setTheme("light"); } bool DThemeManager::eventFilter(QObject *watched, QEvent *event) { D_D(DThemeManager); if (event->type() != QEvent::DynamicPropertyChange) { return QObject::eventFilter(watched, event); } auto widget = qobject_cast(watched); if (!d->watchedDynamicPropertys.contains(widget)) { return QObject::eventFilter(watched, event); } auto propEvent = reinterpret_cast(event); if (!propEvent) { return QObject::eventFilter(watched, event); } auto props = d->watchedDynamicPropertys.value(widget); auto propName = QString::fromLatin1(propEvent->propertyName().data()); if (props.contains(propName) && widget) { widget->setStyleSheet(widget->styleSheet()); widget->style()->unpolish(widget); widget->style()->polish(widget); widget->update(); } return QObject::eventFilter(watched, event); } void DThemeManager::updateThemeOnParentChanged(QWidget *widget) { if (widget->property("_d_dtk_theme").isValid()) { return; } QWidget *base_widget = nullptr; const QString &theme = this->theme(widget, &base_widget); if (!base_widget) { return; } updateWidgetTheme(this, widget, base_widget, theme); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dthememanager.h000066400000000000000000000044331325435343100210640ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTHEMEMANAGER_H #define DTHEMEMANAGER_H #include #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DThemeManagerPrivate; class LIBDTKWIDGETSHARED_EXPORT DThemeManager : public QObject, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: static DThemeManager *instance(); QString theme() const; QString theme(const QWidget *widget, QWidget **baseWidget = nullptr) const; void setTheme(const QString theme); void setTheme(QWidget *widget, const QString theme); QString getQssForWidget(const QString className, const QString &theme = QString()) const; QString getQssForWidget(const QString className, const QWidget *widget) const; QString getQssForWidget(const QWidget *widget) const; static void registerWidget(QWidget *widget, QStringList propertys = QStringList()); // TODO: use blow instead, the only thing should do is rebuilding // static void registerWidget(QWidget *widget, const QStringList &propertys = QStringList()); static void registerWidget(QWidget *widget, const QString &filename, const QStringList &propertys = QStringList()); public Q_SLOTS: void updateQss(); void updateThemeOnParentChanged(QWidget *widget); Q_SIGNALS: void themeChanged(QString theme); void widgetThemeChanged(QWidget *widget, QString theme); protected: DThemeManager(); bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; private: friend class DApplication; D_DECLARE_PRIVATE(DThemeManager) }; DWIDGET_END_NAMESPACE #endif // DTHEMEMANAGER_H dtkwidget-2.0.7.2/src/widgets/dtickeffect.cpp000066400000000000000000000104561325435343100210730ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dtickeffect.h" #include "private/dtickeffect_p.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE DTickEffect::DTickEffect(QWidget *widget, QWidget *parent) : QGraphicsEffect(parent) , DObject(*new DTickEffectPrivate(this)) { D_D(DTickEffect); widget->setGraphicsEffect(this); d->content = widget; d->init(); setDirection(DTickEffect::LeftToRight); setDuration(1000); connect(d->runAnimation, &QVariantAnimation::valueChanged, this, &DTickEffect::update); connect(d->runAnimation, &QVariantAnimation::finished, this, &DTickEffect::finished); } void DTickEffect::draw(QPainter *painter) { D_D(DTickEffect); QPoint offset; QPixmap pixmap; if (sourceIsPixmap()) pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, QGraphicsEffect::NoPad); else pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, QGraphicsEffect::NoPad); QPoint p = d->runAnimation->currentValue().toPoint(); switch (d->direction) { case LeftToRight: offset = QPoint(-pixmap.width() + p.x(), p.y()); break; case RightToLeft: offset = QPoint(pixmap.width() + p.x(), p.y()); break; case TopToBottom: offset = QPoint(p.x(), -pixmap.height() + p.y()); break; case BottomToTop: offset = QPoint(p.x(), pixmap.height() + p.y()); break; default: break; } painter->drawPixmap(d->runAnimation->currentValue().toPoint(), pixmap); painter->drawPixmap(offset, pixmap); } void DTickEffect::play() { D_D(DTickEffect); d->runAnimation->start(); Q_EMIT stateChanged(); } void DTickEffect::stop() { D_D(DTickEffect); d->runAnimation->stop(); Q_EMIT stateChanged(); } void DTickEffect::pause() { D_D(DTickEffect); d->runAnimation->pause(); Q_EMIT stateChanged(); } void DTickEffect::resume() { D_D(DTickEffect); d->runAnimation->resume(); Q_EMIT stateChanged(); } void DTickEffect::setDirection(DTickEffect::Direction direction) { D_D(DTickEffect); if (d->direction == direction) return; d->direction = direction; d->initDirection(); } void DTickEffect::setDuration(const int duration) { D_D(DTickEffect); if (d->duration == duration) return; d->duration = duration; d->runAnimation->setDuration(duration); } DTickEffectPrivate::DTickEffectPrivate(DTickEffect *qq) : DObjectPrivate(qq) { } DTickEffectPrivate::~DTickEffectPrivate() { runAnimation->deleteLater(); } void DTickEffectPrivate::init() { runAnimation = new QVariantAnimation; runAnimation->setLoopCount(-1); } void DTickEffectPrivate::initDirection() { D_Q(DTickEffect); switch (direction) { case DTickEffect::LeftToRight: runAnimation->setStartValue(QPoint(content->x(), content->y())); runAnimation->setEndValue(QPoint(content->width(), content->y())); break; case DTickEffect::RightToLeft: runAnimation->setStartValue(QPoint(content->x(), content->y())); runAnimation->setEndValue(QPoint(-content->width(), content->y())); break; case DTickEffect::TopToBottom: runAnimation->setStartValue(QPoint(content->x(), content->y())); runAnimation->setEndValue(QPoint(content->x(), content->height())); break; case DTickEffect::BottomToTop: runAnimation->setStartValue(QPoint(content->x(), content->y())); runAnimation->setEndValue(QPoint(content->x(), -content->height())); break; default: break; } q->stop(); q->play(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dtickeffect.h000066400000000000000000000030171325435343100205330ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTICKEFFECT_H #define DTICKEFFECT_H #include "dtkwidget_global.h" #include "dobject.h" #include DWIDGET_BEGIN_NAMESPACE class DTickEffectPrivate; class LIBDTKWIDGETSHARED_EXPORT DTickEffect : public QGraphicsEffect, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: explicit DTickEffect(QWidget *widget, QWidget *parent = 0); enum Direction{ LeftToRight, RightToLeft, TopToBottom, BottomToTop }; void play(); void stop(); void pause(); void resume(); void setDirection(Direction direction); void setDuration(const int duration); Q_SIGNALS: void finished(); void stateChanged(); protected: void draw(QPainter *painter) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DTickEffect) }; DWIDGET_END_NAMESPACE #endif // DTICKEFFECT_H dtkwidget-2.0.7.2/src/widgets/dtitlebar.cpp000066400000000000000000000711541325435343100205740ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dtitlebar.h" #include #include #include #include #include #include #include #include "dwindowclosebutton.h" #include "dwindowmaxbutton.h" #include "dwindowminbutton.h" #include "dwindowoptionbutton.h" #include "dlabel.h" #include "dplatformwindowhandle.h" #ifdef Q_OS_LINUX #include "../platforms/x11/xutil.h" #endif #include "daboutdialog.h" #include "dapplication.h" #include "private/dapplication_p.h" #include "dthememanager.h" #include "util/dwindowmanagerhelper.h" #include "dmainwindow.h" DWIDGET_BEGIN_NAMESPACE const int DefaultTitlebarHeight = 40; const int DefaultIconHeight = 24; const int DefaultIconWidth = 24; class DTitlebarPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { protected: DTitlebarPrivate(DTitlebar *qq); private: void init(); QWidget *targetWindow(); // FIXME: get a batter salution // hide title will make eventFilter not work, instead set Height to zero bool isVisableOnFullscreen(); void hideOnFullscreen(); void showOnFullscreen(); void updateFullscreen(); void updateButtonsState(Qt::WindowFlags type); void updateButtonsFunc(); void handleParentWindowStateChange(); void handleParentWindowIdChange(); void _q_toggleWindowState(); void _q_showMinimized(); void _q_onTopWindowMotifHintsChanged(quint32 winId); #ifndef QT_NO_MENU void _q_addDefaultMenuItems(); void _q_helpActionTriggered(); void _q_aboutActionTriggered(); void _q_quitActionTriggered(); #endif QHBoxLayout *mainLayout; DLabel *iconLabel; DLabel *titleLabel; DWindowMinButton *minButton; DWindowMaxButton *maxButton; DWindowCloseButton *closeButton; DWindowOptionButton *optionButton; DImageButton *quitFullButton; QWidget *customWidget = Q_NULLPTR; QWidget *coustomAtea; QWidget *buttonArea; QWidget *titleArea; QWidget *titlePadding; QLabel *separatorTop; QLabel *separator; #ifndef QT_NO_MENU QMenu *menu = Q_NULLPTR; QAction *helpAction = Q_NULLPTR; QAction *aboutAction = Q_NULLPTR; QAction *quitAction = Q_NULLPTR; #endif QWindow *targetWindowHandle = Q_NULLPTR; Qt::WindowFlags disableFlags; bool mousePressed = false; bool embedMode = false; bool autoHideOnFullscreen = false; Q_DECLARE_PUBLIC(DTitlebar) }; DTitlebarPrivate::DTitlebarPrivate(DTitlebar *qq): DObjectPrivate(qq) { } void DTitlebarPrivate::init() { D_Q(DTitlebar); mainLayout = new QHBoxLayout; iconLabel = new DLabel; titleLabel = new DLabel; minButton = new DWindowMinButton; maxButton = new DWindowMaxButton; closeButton = new DWindowCloseButton; optionButton = new DWindowOptionButton; quitFullButton = new DImageButton; coustomAtea = new QWidget; buttonArea = new QWidget; titleArea = new QWidget; titlePadding = new QWidget; separatorTop = new QLabel(q); separator = new QLabel(q); optionButton->setObjectName("DTitlebarDWindowOptionButton"); minButton->setObjectName("DTitlebarDWindowMinButton"); maxButton->setObjectName("DTitlebarDWindowMaxButton"); closeButton->setObjectName("DTitlebarDWindowCloseButton"); quitFullButton->setObjectName("DTitlebarDWindowQuitFullscreenButton"); quitFullButton->hide(); mainLayout->setContentsMargins(6, 0, 0, 0); mainLayout->setSpacing(0); iconLabel->setFixedSize(DefaultIconWidth, DefaultIconHeight); iconLabel->setWindowFlags(Qt::WindowTransparentForInput); titleLabel->setText(qApp->applicationName()); // TODO: use QSS titleLabel->setStyleSheet("font-size: 12px;"); titleLabel->setContentsMargins(0, 0, DefaultIconWidth + 10, 0); titleLabel->setWindowFlags(Qt::WindowTransparentForInput); // q->setStyleSheet("background-color: green;"); separatorTop->setFixedHeight(1); separatorTop->setStyleSheet("background: rgba(0, 0, 0, 20);"); separatorTop->hide(); separatorTop->setWindowFlags(Qt::WindowTransparentForInput); separator->setFixedHeight(1); separator->setStyleSheet("background: rgba(0, 0, 0, 20);"); separator->hide(); separator->setWindowFlags(Qt::WindowTransparentForInput); QHBoxLayout *buttonAreaLayout = new QHBoxLayout; buttonAreaLayout->setContentsMargins(0, 1, 0, 0); buttonAreaLayout->setMargin(0); buttonAreaLayout->setSpacing(0); buttonAreaLayout->addWidget(optionButton); buttonAreaLayout->addWidget(minButton); buttonAreaLayout->addWidget(maxButton); buttonAreaLayout->addWidget(closeButton); buttonAreaLayout->addWidget(quitFullButton); buttonArea->setLayout(buttonAreaLayout); QHBoxLayout *titleAreaLayout = new QHBoxLayout; titleAreaLayout->setContentsMargins(4, 0, 10 + iconLabel->width(), 0); titleAreaLayout->setSpacing(0); titleAreaLayout->addWidget(iconLabel); titleAreaLayout->setAlignment(iconLabel, Qt::AlignLeft); titlePadding->setFixedSize(buttonArea->size()); titlePadding->setWindowFlags(Qt::WindowTransparentForInput); titleAreaLayout->addWidget(titlePadding); titleAreaLayout->addStretch(); titleAreaLayout->addWidget(titleLabel); titleAreaLayout->setAlignment(titleLabel, Qt::AlignCenter); titleAreaLayout->addStretch(); titleArea->setLayout(titleAreaLayout); titleArea->setWindowFlags(Qt::WindowTransparentForInput); QHBoxLayout *coustomAteaLayout = new QHBoxLayout; coustomAteaLayout->setMargin(0); coustomAteaLayout->setSpacing(0); coustomAteaLayout->addWidget(titleArea); coustomAtea->setLayout(coustomAteaLayout); mainLayout->addWidget(coustomAtea); mainLayout->addWidget(buttonArea); mainLayout->setAlignment(buttonArea, Qt::AlignRight | Qt::AlignVCenter); q->setLayout(mainLayout); q->setFixedHeight(DefaultTitlebarHeight); q->setMinimumHeight(DefaultTitlebarHeight); coustomAtea->setFixedHeight(q->height()); buttonArea->setFixedHeight(q->height()); q->connect(quitFullButton, &DImageButton::clicked, q, [ = ]() { bool isFullscreen = targetWindow()->windowState().testFlag(Qt::WindowFullScreen); if (isFullscreen) { targetWindow()->showNormal(); } else { targetWindow()->showFullScreen(); } }); q->connect(optionButton, &DWindowOptionButton::clicked, q, &DTitlebar::optionClicked); q->connect(DWindowManagerHelper::instance(), SIGNAL(windowMotifWMHintsChanged(quint32)), q, SLOT(_q_onTopWindowMotifHintsChanged(quint32))); } QWidget *DTitlebarPrivate::targetWindow() { D_Q(DTitlebar); return q->topLevelWidget()->window(); } bool DTitlebarPrivate::isVisableOnFullscreen() { D_Q(DTitlebar); return !q->property("_restore_height").isValid(); } void DTitlebarPrivate::hideOnFullscreen() { D_Q(DTitlebar); q->setProperty("_restore_height", q->height()); q->setFixedHeight(0); } void DTitlebarPrivate::showOnFullscreen() { D_Q(DTitlebar); if (q->property("_restore_height").isValid()) { q->setFixedHeight(q->property("_restore_height").toInt()); q->setProperty("_restore_height", QVariant()); } } void DTitlebarPrivate::updateFullscreen() { D_Q(DTitlebar); if (!autoHideOnFullscreen) { return; } bool isFullscreen = targetWindow()->windowState().testFlag(Qt::WindowFullScreen); auto mainWindow = qobject_cast(targetWindow()); if (!isFullscreen) { quitFullButton->hide(); mainWindow->setMenuWidget(q); showOnFullscreen(); } else { // must set to empty quitFullButton->show(); mainWindow->menuWidget()->setParent(nullptr); mainWindow->setMenuWidget(Q_NULLPTR); q->setParent(mainWindow); q->show(); hideOnFullscreen(); } } void DTitlebarPrivate::updateButtonsState(Qt::WindowFlags type) { D_Q(DTitlebar); bool useDXcb = DPlatformWindowHandle::isEnabledDXcb(targetWindow()); bool isFullscreen = targetWindow()->windowState().testFlag(Qt::WindowFullScreen); bool showTitle = (type.testFlag(Qt::WindowTitleHint) || !useDXcb) && !embedMode; if (titleLabel) { titleLabel->setVisible(showTitle); } if (iconLabel) { iconLabel->setVisible(showTitle); } // Never show in embed/fullscreen bool forceHide = embedMode || isFullscreen; bool showMin = (type.testFlag(Qt::WindowMinimizeButtonHint) || !useDXcb) && !forceHide; minButton->setVisible(showMin); bool allowResize = true; if (q->window() && q->window()->windowHandle()) { auto functions_hints = DWindowManagerHelper::getMotifFunctions(q->window()->windowHandle()); allowResize = functions_hints.testFlag(DWindowManagerHelper::FUNC_RESIZE); } bool showMax = (type.testFlag(Qt::WindowMaximizeButtonHint) || !useDXcb) && !forceHide && allowResize; maxButton->setVisible(showMax); bool showClose = (type.testFlag(Qt::WindowCloseButtonHint) || !useDXcb) && !forceHide; closeButton->setVisible(showClose); bool showOption = (type.testFlag(Qt::WindowSystemMenuHint) || !useDXcb) && !isFullscreen; optionButton->setVisible(showOption); buttonArea->adjustSize(); buttonArea->resize(buttonArea->size()); if (titlePadding) { titlePadding->setFixedSize(buttonArea->size()); } } void DTitlebarPrivate::updateButtonsFunc() { optionButton->setDisabled(disableFlags.testFlag(Qt::WindowSystemMenuHint)); minButton->setDisabled(disableFlags.testFlag(Qt::WindowMinimizeButtonHint)); maxButton->setDisabled(disableFlags.testFlag(Qt::WindowMaximizeButtonHint)); closeButton->setDisabled(disableFlags.testFlag(Qt::WindowCloseButtonHint)); DWindowManagerHelper::setMotifFunctions( targetWindow()->windowHandle(), DWindowManagerHelper::FUNC_MAXIMIZE, !disableFlags.testFlag(Qt::WindowMaximizeButtonHint)); DWindowManagerHelper::setMotifFunctions( targetWindow()->windowHandle(), DWindowManagerHelper::FUNC_MINIMIZE, !disableFlags.testFlag(Qt::WindowMinimizeButtonHint)); DWindowManagerHelper::setMotifFunctions( targetWindow()->windowHandle(), DWindowManagerHelper::FUNC_CLOSE, !disableFlags.testFlag(Qt::WindowCloseButtonHint)); } void DTitlebarPrivate::handleParentWindowStateChange() { maxButton->setMaximized(targetWindow()->windowState() == Qt::WindowMaximized); updateFullscreen(); updateButtonsState(targetWindow()->windowFlags()); } //! //! \brief DTitlebarPrivate::handleParentWindowIdChange //! Them WindowStateChnage Event will miss some state changed message, //! So use windowHandle::windowStateChanged instead void DTitlebarPrivate::handleParentWindowIdChange() { D_Q(DTitlebar); if (!targetWindowHandle) { targetWindowHandle = targetWindow()->windowHandle(); targetWindowHandle->disconnect(targetWindow()->windowHandle(), &QWindow::windowStateChanged, q, Q_NULLPTR); targetWindowHandle->connect(targetWindow()->windowHandle(), &QWindow::windowStateChanged, q, [ = ](Qt::WindowState) { handleParentWindowStateChange(); }); } else if (targetWindow()->windowHandle() != targetWindowHandle) { // Parent change???, show never here qWarning() << "targetWindowHandle change" << targetWindowHandle << targetWindow()->windowHandle(); } } void DTitlebarPrivate::_q_toggleWindowState() { QWidget *parentWindow = targetWindow(); if (!parentWindow || disableFlags.testFlag(Qt::WindowMaximizeButtonHint)) { return; } if (parentWindow->isMaximized()) { parentWindow->showNormal(); } else if (!parentWindow->isFullScreen() && (maxButton->isVisible())) { maxButton->setState(DImageButton::Normal); parentWindow->showMaximized(); } } void DTitlebarPrivate::_q_showMinimized() { minButton->setState(DImageButton::Normal); targetWindow()->showMinimized(); } void DTitlebarPrivate::_q_onTopWindowMotifHintsChanged(quint32 winId) { D_QC(DTitlebar); if (!DPlatformWindowHandle::isEnabledDXcb(targetWindow())) { q->disconnect(DWindowManagerHelper::instance(), SIGNAL(windowMotifWMHintsChanged(quint32)), q, SLOT(_q_onTopWindowMotifHintsChanged(quint32))); return; } if (winId != q->window()->internalWinId()) { return; } DWindowManagerHelper::MotifDecorations decorations_hints = DWindowManagerHelper::getMotifDecorations(q->window()->windowHandle()); if (titleLabel) { titleLabel->setVisible(decorations_hints.testFlag(DWindowManagerHelper::DECOR_TITLE)); } if (iconLabel) { iconLabel->setVisible(decorations_hints.testFlag(DWindowManagerHelper::DECOR_TITLE)); } updateButtonsState(targetWindow()->windowFlags()); // minButton->setEnabled(functions_hints.testFlag(DWindowManagerHelper::FUNC_MINIMIZE) && !embedMode); // maxButton->setEnabled(functions_hints.testFlag(DWindowManagerHelper::FUNC_MAXIMIZE) && !embedMode); // closeButton->setEnabled(functions_hints.testFlag(DWindowManagerHelper::FUNC_CLOSE) && !embedMode); // // sync button state // if (minButton->isEnabled()) { // disableFlags &= ~Qt::WindowMinimizeButtonHint; // } else { // disableFlags |= Qt::WindowMinimizeButtonHint; // } // if (maxButton->isEnabled()) { // disableFlags &= ~Qt::WindowMaximizeButtonHint; // } else { // disableFlags |= Qt::WindowMaximizeButtonHint; // } // if (closeButton->isEnabled()) { // disableFlags &= ~Qt::WindowCloseButtonHint; // } else { // disableFlags |= Qt::WindowCloseButtonHint; // } if (titlePadding) { titlePadding->setFixedSize(buttonArea->size()); } } #ifndef QT_NO_MENU void DTitlebarPrivate::_q_addDefaultMenuItems() { D_Q(DTitlebar); if (!menu) { q->setMenu(new QMenu(q)); } // add help menu item. if (!helpAction && DApplicationPrivate::isUserManualExists()) { helpAction = new QAction(qApp->translate("TitleBarMenu", "Help"), menu); QObject::connect(helpAction, SIGNAL(triggered(bool)), q, SLOT(_q_helpActionTriggered())); menu->addAction(helpAction); } // add about menu item. if (!aboutAction) { aboutAction = new QAction(qApp->translate("TitleBarMenu", "About"), menu); QObject::connect(aboutAction, SIGNAL(triggered(bool)), q, SLOT(_q_aboutActionTriggered())); menu->addAction(aboutAction); } // add quit menu item. if (!quitAction) { quitAction = new QAction(qApp->translate("TitleBarMenu", "Exit"), menu); QObject::connect(quitAction, SIGNAL(triggered(bool)), q, SLOT(_q_quitActionTriggered())); menu->addAction(quitAction); } } void DTitlebarPrivate::_q_helpActionTriggered() { DApplication *dapp = qobject_cast(qApp); if (dapp) { dapp->handleHelpAction(); } } void DTitlebarPrivate::_q_aboutActionTriggered() { DApplication *dapp = qobject_cast(qApp); if (dapp) { dapp->handleAboutAction(); } } void DTitlebarPrivate::_q_quitActionTriggered() { DApplication *dapp = qobject_cast(qApp); if (dapp) { dapp->handleQuitAction(); } } #endif /** * \class DTitlebar * \brief The DTitlebar class is an universal title bar on the top of windows. * \param parent is the parent widget to be attached on. * * Usually you don't need to construct a DTitlebar instance by your self, you * can get an DTitlebar instance by DMainWindow::titlebar . */ /** * @brief DTitlebar::DTitlebar create an default widget with icon/title/and bottons * @param parent */ DTitlebar::DTitlebar(QWidget *parent) : QFrame(parent), DObject(*new DTitlebarPrivate(this)) { if (DApplication::buildDtkVersion() < DTK_VERSION_CHECK(2, 0, 6, 1)) { setBackgroundTransparent(true); } DThemeManager::registerWidget(this, QStringList({"transparent"})); D_D(DTitlebar); d->init(); d->buttonArea->adjustSize(); d->buttonArea->resize(d->buttonArea->size()); d->titlePadding->setFixedSize(d->buttonArea->size()); } #ifndef QT_NO_MENU /** * @brief DTitlebar::menu holds the QMenu object attached to this title bar. * @return the QMenu object it holds, returns null if there's no one set. */ QMenu *DTitlebar::menu() const { D_DC(DTitlebar); return d->menu; } /** * @brief DTitlebar::setMenu attaches a QMenu object to the title bar. * @param menu is the target menu. */ void DTitlebar::setMenu(QMenu *menu) { D_D(DTitlebar); d->menu = menu; if (d->menu) { disconnect(this, &DTitlebar::optionClicked, 0, 0); connect(this, &DTitlebar::optionClicked, this, &DTitlebar::showMenu); } } #endif /** * @brief DTitlebar::customWidget * @return the customized widget used in this title bar. * * One can set customized widget to show some extra widgets on the title bar. * \see DTitlebar::setCustomWidget() */ QWidget *DTitlebar::customWidget() const { D_DC(DTitlebar); return d->customWidget; } /// /// \brief setWindowFlags /// \param type /// accpet WindowTitleHint, WindowSystemMenuHint, WindowMinimizeButtonHint, WindowMaximizeButtonHint /// and WindowMinMaxButtonsHint. void DTitlebar::setWindowFlags(Qt::WindowFlags type) { D_D(DTitlebar); d->targetWindow()->setWindowFlags(type); } #ifndef QT_NO_MENU void DTitlebar::showMenu() { D_D(DTitlebar); if (d->menu) { d->optionButton->setState(DImageButton::Normal); d->menu->exec(d->optionButton->mapToGlobal(d->optionButton->rect().bottomLeft())); } } #endif void DTitlebar::showEvent(QShowEvent *event) { D_D(DTitlebar); d->separatorTop->setFixedWidth(width()); d->separatorTop->move(0, 0); d->separator->setFixedWidth(width()); d->separator->move(0, height() - d->separator->height()); #ifndef QT_NO_MENU d->_q_addDefaultMenuItems(); #endif QWidget::showEvent(event); if (DPlatformWindowHandle::isEnabledDXcb(window())) { d->_q_onTopWindowMotifHintsChanged( static_cast(window()->internalWinId())); } } void DTitlebar::mousePressEvent(QMouseEvent *event) { D_D(DTitlebar); d->mousePressed = (event->buttons() == Qt::LeftButton); if (event->button() == Qt::RightButton) { DWindowManagerHelper::popupSystemWindowMenu(window()->windowHandle()); return; } #ifdef DTK_TITLE_DRAG_WINDOW Q_EMIT mousePosPressed(event->buttons(), event->globalPos()); #endif Q_EMIT mousePressed(event->buttons()); } void DTitlebar::mouseReleaseEvent(QMouseEvent *event) { D_D(DTitlebar); if (event->buttons() == Qt::LeftButton) { d->mousePressed = false; } } bool DTitlebar::eventFilter(QObject *obj, QEvent *event) { D_D(DTitlebar); if (obj == d->targetWindow()) { switch (event->type()) { case QEvent::ShowToParent: d->handleParentWindowIdChange(); d->updateButtonsFunc(); d->updateButtonsState(d->targetWindow()->windowFlags()); break; case QEvent::Resize: if (d->autoHideOnFullscreen) { setFixedWidth(d->targetWindow()->width()); } break; case QEvent::HoverMove: { auto mouseEvent = reinterpret_cast(event); bool isFullscreen = d->targetWindow()->windowState().testFlag(Qt::WindowFullScreen); if (isFullscreen && d->autoHideOnFullscreen) { if (mouseEvent->pos().y() > height() && d->isVisableOnFullscreen()) { d->hideOnFullscreen(); } if (mouseEvent->pos().y() < 2) { d->showOnFullscreen(); } } break; } default: break; } } return QWidget::eventFilter(obj, event); } void DTitlebar::resizeEvent(QResizeEvent *event) { D_D(DTitlebar); d->optionButton->setFixedHeight(event->size().height()); d->minButton->setFixedHeight(event->size().height()); d->maxButton->setFixedHeight(event->size().height()); d->closeButton->setFixedHeight(event->size().height()); d->separatorTop->setFixedWidth(event->size().width()); d->separator->setFixedWidth(event->size().width()); return QWidget::resizeEvent(event); } /** * @brief DTitlebar::setCustomWidget is an overloaded function. * @param w is the widget to be used as the customize widget shown in the title * bar. * @param fixCenterPos indicates whether it should automatically move the * customize widget to the horizontal center of the title bar or not. */ void DTitlebar::setCustomWidget(QWidget *w, bool fixCenterPos) { setCustomWidget(w, Qt::AlignCenter, fixCenterPos); } /** * @brief DTitlebar::setCustomWidget sets a customized widget to be used as the * central content of the title bar. * @param w is the widget to be used as the customize widget shown in the title * bar. * @param wflag is used to vertically align the widget. * @param fixCenterPos indicates whether it should automatically move the * customize widget to the horizontal center of the title bar or not. */ void DTitlebar::setCustomWidget(QWidget *w, Qt::AlignmentFlag wflag, bool fixCenterPos) { D_D(DTitlebar); if (!w || w == d->titleArea) { return; } QSize old = d->buttonArea->size(); QHBoxLayout *l = new QHBoxLayout; l->setSpacing(0); l->setMargin(0); if (fixCenterPos) { d->titlePadding = new QWidget; d->titlePadding->setFixedSize(old); l->addWidget(d->titlePadding); } l->addWidget(w, 0, wflag); qDeleteAll(d->coustomAtea->children()); d->titleLabel = Q_NULLPTR; d->titleArea = Q_NULLPTR; d->iconLabel = Q_NULLPTR; d->titlePadding = Q_NULLPTR; d->coustomAtea->setLayout(l); d->buttonArea->resize(old); d->customWidget = w; w->resize(d->coustomAtea->size()); } /** * @brief DTitlebar::setFixedHeight change the height of the title bar to * another value. * @param h is the target height. */ void DTitlebar::setFixedHeight(int h) { D_D(DTitlebar); QWidget::setFixedHeight(h); d->coustomAtea->setFixedHeight(h); d->buttonArea->setFixedHeight(h); } /** * @brief DTitlebar::setBackgroundTransparent set the title background transparent * @param transparent is the targeting value. */ void DTitlebar::setBackgroundTransparent(bool transparent) { setProperty("transparent", transparent); } /** * @brief DTitlebar::setSeparatorVisible sets the bottom separator of the title * bar and the window contents to be visible or not. * @param visible is the targeting value. */ void DTitlebar::setSeparatorVisible(bool visible) { D_D(DTitlebar); if (visible) { d->separator->show(); d->separator->raise(); } else { d->separator->hide(); } } /** * @brief DTitlebar::setTitle sets the title to be shown on the title bar. * @param title is the text to be used as the window title. */ void DTitlebar::setTitle(const QString &title) { D_D(DTitlebar); if (d->titleLabel && !d->embedMode) { d->titleLabel->setText(title); } else if (parentWidget()) { parentWidget()->setWindowTitle(title); } } /*! * \brief Use setIcon(const QIcon &icon) instead */ void DTitlebar::setIcon(const QPixmap &icon) { D_D(DTitlebar); if (d->titleLabel && !d->embedMode) { d->titleLabel->setContentsMargins(0, 0, 0, 0); d->iconLabel->setPixmap(icon.scaled(DefaultIconWidth * icon.devicePixelRatio(), DefaultIconHeight * icon.devicePixelRatio(), Qt::KeepAspectRatio)); } } /*! * @brief DTitlebar::setIcon sets the icon to be shown on the title bar. * @param icon is to be used as the window icon. */ void DTitlebar::setIcon(const QIcon &icon) { D_D(DTitlebar); if (d->titleLabel && !d->embedMode) { d->titleLabel->setContentsMargins(0, 0, 0, 0); d->iconLabel->setPixmap(icon.pixmap(QSize(DefaultIconWidth, DefaultIconHeight))); } else if (parentWidget()) { parentWidget()->setWindowIcon(icon); } } void DTitlebar::setWindowState(Qt::WindowState windowState) { D_D(DTitlebar); d->maxButton->setWindowState(windowState); } void DTitlebar::toggleWindowState() { D_D(DTitlebar); d->_q_toggleWindowState(); } /** * @brief DTitlebar::buttonAreaWidth returns the width of the area that all the * window buttons occupies. */ int DTitlebar::buttonAreaWidth() const { D_DC(DTitlebar); return d->buttonArea->width(); } /** * @brief DTitlebar::separatorVisible returns the visibility of the bottom * separator of the titlebar. */ bool DTitlebar::separatorVisible() const { D_DC(DTitlebar); return d->separator->isVisible(); } bool DTitlebar::autoHideOnFullscreen() const { D_DC(DTitlebar); return d->autoHideOnFullscreen; } void DTitlebar::setAutoHideOnFullscreen(bool autohide) { D_D(DTitlebar); d->autoHideOnFullscreen = autohide; } /** * @brief DTitlebar::setVisible overrides QWidget::setVisible(bool visible) */ void DTitlebar::setVisible(bool visible) { D_D(DTitlebar); if (visible == isVisible()) { return; } QWidget::setVisible(visible); if (visible) { if (!d->targetWindow()) { return; } d->targetWindow()->installEventFilter(this); connect(d->maxButton, SIGNAL(clicked()), this, SLOT(_q_toggleWindowState())); connect(this, SIGNAL(doubleClicked()), this, SLOT(_q_toggleWindowState())); connect(d->minButton, SIGNAL(clicked()), this, SLOT(_q_showMinimized())); connect(d->closeButton, &DWindowCloseButton::clicked, d->targetWindow(), &QWidget::close); } else { if (!d->targetWindow()) { return; } d->targetWindow()->removeEventFilter(this); disconnect(d->maxButton, SIGNAL(clicked()), this, SLOT(_q_toggleWindowState())); disconnect(this, SIGNAL(doubleClicked()), this, SLOT(_q_toggleWindowState())); disconnect(d->minButton, SIGNAL(clicked()), this, SLOT(_q_showMinimized())); disconnect(d->closeButton, &DWindowCloseButton::clicked, d->targetWindow(), &QWidget::close); } } /** * @brief DTitlebar::setEmbedMode set a titar is in parent; */ void DTitlebar::setEmbedMode(bool visible) { D_D(DTitlebar); d->embedMode = visible; d->separatorTop->setVisible(visible); d->updateButtonsState(windowFlags()); } /** * @brief DTitlebar::resize resizes the title bar. * @param w is the target width. * @param h is the target height. */ void DTitlebar::resize(int w, int h) { D_DC(DTitlebar); if (d->customWidget) { d->customWidget->resize(w - d->buttonArea->width(), h); } } /** * @brief DTitlebar::resize is an overloaded function. * @param sz the target size. * * @see DTitlebar::resize(int w, int h) */ void DTitlebar::resize(const QSize &sz) { DTitlebar::resize(sz.width(), sz.height()); } void DTitlebar::setDisableFlags(Qt::WindowFlags flags) { D_D(DTitlebar); d->disableFlags = flags; d->updateButtonsFunc(); } Qt::WindowFlags DTitlebar::disableFlags() const { D_DC(DTitlebar); return d->disableFlags; } void DTitlebar::mouseMoveEvent(QMouseEvent *event) { Qt::MouseButton button = event->buttons() & Qt::LeftButton ? Qt::LeftButton : Qt::NoButton; if (event->buttons() == Qt::LeftButton /*&& d->mousePressed*/) { Q_EMIT mouseMoving(button); } #ifdef DTK_TITLE_DRAG_WINDOW D_D(DTitlebar); if (d->mousePressed) { Q_EMIT mousePosMoving(button, event->globalPos()); } #endif QWidget::mouseMoveEvent(event); } void DTitlebar::mouseDoubleClickEvent(QMouseEvent *event) { D_D(DTitlebar); if (event->buttons() == Qt::LeftButton) { d->mousePressed = false; Q_EMIT doubleClicked(); } } DWIDGET_END_NAMESPACE #include "moc_dtitlebar.cpp" dtkwidget-2.0.7.2/src/widgets/dtitlebar.h000066400000000000000000000067141325435343100202410ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTITLEBAR_H #define DTITLEBAR_H #include #include #include #include "dtkwidget_global.h" DWIDGET_BEGIN_NAMESPACE class DTitlebarPrivate; class LIBDTKWIDGETSHARED_EXPORT DTitlebar : public QFrame, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: explicit DTitlebar(QWidget *parent = Q_NULLPTR); #ifndef QT_NO_MENU QMenu *menu() const; void setMenu(QMenu *menu); #endif QWidget *customWidget() const; void setCustomWidget(QWidget *, bool fixCenterPos = false); void setCustomWidget(QWidget *, Qt::AlignmentFlag flag = Qt::AlignCenter, bool fixCenterPos = false); D_DECL_DEPRECATED void setWindowFlags(Qt::WindowFlags type); int buttonAreaWidth() const; bool separatorVisible() const; bool autoHideOnFullscreen() const; void setAutoHideOnFullscreen(bool autohide); void setVisible(bool visible) Q_DECL_OVERRIDE; void setEmbedMode(bool embed); void resize(int width, int height); void resize(const QSize &); void setDisableFlags(Qt::WindowFlags flags); Qt::WindowFlags disableFlags() const; Q_SIGNALS: void optionClicked(); void doubleClicked(); void mousePressed(Qt::MouseButtons buttons); void mouseMoving(Qt::MouseButton botton); #ifdef DTK_TITLE_DRAG_WINDOW void mousePosPressed(Qt::MouseButtons buttons, QPoint pos); void mousePosMoving(Qt::MouseButton botton, QPoint pos); #endif public Q_SLOTS: void setFixedHeight(int h); void setBackgroundTransparent(bool transparent); void setSeparatorVisible(bool visible); void setTitle(const QString &title); void setIcon(const QIcon &icon); D_DECL_DEPRECATED void setIcon(const QPixmap &icon); D_DECL_DEPRECATED void setWindowState(Qt::WindowState windowState); /// Maximized/Minumized void toggleWindowState(); private Q_SLOTS: #ifndef QT_NO_MENU void showMenu(); #endif protected: bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DTitlebar) D_PRIVATE_SLOT(void _q_toggleWindowState()) D_PRIVATE_SLOT(void _q_showMinimized()) D_PRIVATE_SLOT(void _q_onTopWindowMotifHintsChanged(quint32)) #ifndef QT_NO_MENU D_PRIVATE_SLOT(void _q_addDefaultMenuItems()) D_PRIVATE_SLOT(void _q_helpActionTriggered()) D_PRIVATE_SLOT(void _q_aboutActionTriggered()) D_PRIVATE_SLOT(void _q_quitActionTriggered()) #endif }; DWIDGET_END_NAMESPACE #endif // DTITLEBAR_H dtkwidget-2.0.7.2/src/widgets/dtoast.cpp000066400000000000000000000076171325435343100201230ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * Author: Iceyer * * Maintainer: Iceyer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dtoast.h" #include #include #include #include #include #include #include "dthememanager.h" #include "dgraphicsgloweffect.h" #include "dhidpihelper.h" DWIDGET_BEGIN_NAMESPACE class DToastPrivate: public DTK_CORE_NAMESPACE::DObjectPrivate { public: DToastPrivate(DToast *qq); QIcon icon; QLabel *iconLabel = Q_NULLPTR; QLabel *textLabel = Q_NULLPTR; QPropertyAnimation *animation = Q_NULLPTR; DGraphicsGlowEffect *effect = Q_NULLPTR; void initUI(); private: D_DECLARE_PUBLIC(DToast) }; DToast::DToast(QWidget *parent) : QFrame(parent), DObject(*new DToastPrivate(this)) { D_D(DToast); DThemeManager::registerWidget(this); d->initUI(); } DToast::~DToast() { } QString DToast::text() const { D_DC(DToast); return d->textLabel->text(); } QIcon DToast::icon() const { D_DC(DToast); return d->icon; } qreal DToast::opacity() const { D_DC(DToast); return d->effect->opacity(); } void DToast::setText(QString text) { D_D(DToast); d->textLabel->setVisible(true); d->textLabel->setText(text); } void DToast::setIcon(QString iconfile) { D_D(DToast); d->icon = QIcon(iconfile); d->iconLabel->setVisible(true); d->iconLabel->setPixmap(DHiDPIHelper::loadNxPixmap(iconfile)); } void DToast::setIcon(QIcon icon, QSize defaultSize) { D_D(DToast); d->icon = icon; d->iconLabel->setVisible(true); d->iconLabel->setPixmap(d->icon.pixmap(icon.actualSize(defaultSize))); } void DToast::setOpacity(qreal opacity) { D_D(DToast); d->effect->setOpacity(opacity); update(); } void DToast::pop() { Q_D(DToast); adjustSize(); show(); if (d->animation) { return; } d->animation = new QPropertyAnimation(this, "opacity"); d->animation->setDuration(2000); d->animation->setStartValue(0); d->animation->setKeyValueAt(0.4, 1.0); d->animation->setKeyValueAt(0.8, 1.0); d->animation->setEndValue(0); d->animation->start(); d->animation->connect(d->animation, &QPropertyAnimation::finished, this, [ = ]() { hide(); d->animation->deleteLater(); d->animation = Q_NULLPTR; }); } void DToast::pack() { Q_D(DToast); hide(); if (d->animation) { d->animation->stop(); d->animation->deleteLater(); d->animation = Q_NULLPTR; } } DToastPrivate::DToastPrivate(DToast *qq) : DObjectPrivate(qq) { } void DToastPrivate::initUI() { D_Q(DToast); q->setWindowFlags(q->windowFlags() | Qt::WindowStaysOnTopHint); auto layout = new QHBoxLayout(q); layout->setContentsMargins(10, 10, 10, 10); layout->setSpacing(12); iconLabel = new QLabel; iconLabel->setVisible(false); textLabel = new QLabel; textLabel->setVisible(false); layout->addWidget(iconLabel); layout->addWidget(textLabel); effect = new DGraphicsGlowEffect(q); effect->setBlurRadius(20.0); effect->setColor(QColor(0, 0, 0, 255 / 10)); effect->setOffset(0, 0); q->setGraphicsEffect(effect); q->hide(); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dtoast.h000066400000000000000000000030021325435343100175500ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * Author: Iceyer * * Maintainer: Iceyer * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include #include "dtkwidget_global.h" #include DWIDGET_BEGIN_NAMESPACE class DToastPrivate; class LIBDTKWIDGETSHARED_EXPORT DToast : public QFrame, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) public: explicit DToast(QWidget *parent = 0); ~DToast(); QString text() const; QIcon icon() const; public Q_SLOTS: void pop(); void pack(); void setText(QString text); void setIcon(QString icon); void setIcon(QIcon icon, QSize defaultSize = QSize(20, 20)); private: qreal opacity() const; void setOpacity(qreal); D_DECLARE_PRIVATE(DToast) }; DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dvideowidget.cpp000066400000000000000000000256211325435343100212760ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dvideowidget.h" #include #include #include #include #include #include #include #include DWIDGET_BEGIN_NAMESPACE class VideoFormatProxy : public QAbstractVideoSurface { Q_OBJECT public: VideoFormatProxy(QObject *parent); QVideoFrame& currentFrame() const; protected: bool present(const QVideoFrame &frame); QList supportedPixelFormats( QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; bool isFormatSupported(const QVideoSurfaceFormat &format) const; private: QVideoFrame m_currentFrame; QVideoFrame m_lastFrame; friend class DVideoWidget; Q_SIGNALS: void currentFrameChanged(); }; VideoFormatProxy::VideoFormatProxy(QObject *parent): QAbstractVideoSurface(parent) { } QVideoFrame& VideoFormatProxy::currentFrame() const { return const_cast(m_currentFrame); } bool VideoFormatProxy::present(const QVideoFrame &frame) { m_currentFrame = frame; if (frame.isValid()) m_lastFrame = frame; Q_EMIT currentFrameChanged(); return true; } QList VideoFormatProxy::supportedPixelFormats(QAbstractVideoBuffer::HandleType) const { return QList() << QVideoFrame::Format_RGB32 << QVideoFrame::Format_ARGB32 << QVideoFrame::Format_ARGB32_Premultiplied << QVideoFrame::Format_RGB565 << QVideoFrame::Format_RGB555; } bool VideoFormatProxy::isFormatSupported(const QVideoSurfaceFormat &format) const { return QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()) != QImage::Format_Invalid; } class DVideoWidgetPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DVideoWidgetPrivate(DVideoWidget *qq); VideoFormatProxy *formatProxy; QPointer player; bool mirroredHorizontal = false; bool mirroredVertical = false; qreal scale = 1; Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio; int brightness = 0; int contrast = 0; int hue = 0; int saturation = 0; bool round = false; qreal ratio = 1; D_DECLARE_PUBLIC(DVideoWidget) }; DVideoWidgetPrivate::DVideoWidgetPrivate(DVideoWidget *qq) : DObjectPrivate(qq) , formatProxy(new VideoFormatProxy(qq)) { qq->connect(formatProxy, &VideoFormatProxy::currentFrameChanged, qq, static_cast(&DVideoWidget::repaint)); } /*! * \class DVideoWidget * \brief The DVideoWidget class provides a widget which presents video produced * by a media object. * * Since the last frame that played is preserved, it always has better user * experience looping some media. Also it supports video flip (both vertically * or horizontally), video scale and rounded video clip. * * It's usually used just to play video animations like the one presented in * dde-zone settings page. If you want to play video or other media objects, * please refer to QVideoWidget for better preformance or support. * * \param parent is the parent widget to be attached on. */ DVideoWidget::DVideoWidget(QWidget *parent) : QWidget(parent) , DObject(*new DVideoWidgetPrivate(this)) { } /*! * \property DVideoWidget::mirroredHorizontal * \brief indicates whether the video is horizontally flipped. */ bool DVideoWidget::mirroredHorizontal() const { D_DC(DVideoWidget); return d->mirroredHorizontal; } /*! * \property DVideoWidget::mirroredVertical * \brief indicates whether the video is vertically flipped. */ bool DVideoWidget::mirroredVertical() const { D_DC(DVideoWidget); return d->mirroredVertical; } /*! * @brief DVideoWidget::paint paints a specific QVideoFrame onto the widget. * @param frame is the target video frame. */ void DVideoWidget::paint(const QVideoFrame &frame) { D_DC(DVideoWidget); QPainter painter(this); QImage image( frame.bits(), frame.width(), frame.height(), frame.bytesPerLine(), QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat())); painter.drawImage(0, 0, image.mirrored(d->mirroredHorizontal, d->mirroredVertical)); } /*! * \property DVideoWidget::scale * \brief the scale ratio used to paint the video frames. */ qreal DVideoWidget::scale() const { D_DC(DVideoWidget); return d->scale; } /*! * \property DVideoWidget::aspectRatioMode * \brief holds the current aspect ratio. */ Qt::AspectRatioMode DVideoWidget::aspectRatioMode() const { D_DC(DVideoWidget); return d->aspectRatioMode; } void DVideoWidget::setSourceVideoPixelRatio(const qreal ratio) { D_D(DVideoWidget); d->ratio = ratio; } const qreal DVideoWidget::sourceVideoPixelRatio() const { D_DC(DVideoWidget); return d->ratio; } /*! * \property DVideoWidget::brightness * \brief returns the brightness adjust setting. * * \note * This property is not implemented. */ int DVideoWidget::brightness() const { D_DC(DVideoWidget); return d->brightness; } /*! * \property DVideoWidget::contrast * \brief returns the contrast adjust setting. * * \note * This property is not implemented. */ int DVideoWidget::contrast() const { D_DC(DVideoWidget); return d->contrast; } /*! * \property DVideoWidget::hue * \brief returns the hue adjust setting. * * \note * This property is not implemented. */ int DVideoWidget::hue() const { D_DC(DVideoWidget); return d->hue; } /*! * \property DVideoWidget::saturation * \brief This property holds an adjustment to the saturation of displayed video. * * \note * This property is not implemented. */ int DVideoWidget::saturation() const { D_DC(DVideoWidget); return d->saturation; } /** * @brief DVideoWidget::currentFrame * @return the current frame displaying. */ const QVideoFrame *DVideoWidget::currentFrame() const { D_DC(DVideoWidget); if (d->formatProxy) { return &d->formatProxy->currentFrame(); } return NULL; } /** * @brief DVideoWidget::capture grabs the current frame. * @return a QPixmap representing the current frame. */ QPixmap DVideoWidget::capture() { return grab(); } /*! * \property DVideoWidget::round * \brief controls whether the painted video frame are rounded or not. */ bool DVideoWidget::round() const { D_DC(DVideoWidget); return d->round; } /** * @brief DVideoWidget::setSource sets a QCamera source to be tracked. * @param source is the target camera source. */ void DVideoWidget::setSource(QCamera *source) { Q_ASSERT(source); D_DC(DVideoWidget); source->setCaptureMode(QCamera::CaptureStillImage); source->setViewfinder(d->formatProxy); } /** * @brief DVideoWidget::setSource sets a QMediaPlayer source to be played. * @param source is the target media player source. */ void DVideoWidget::setSource(QMediaPlayer *source) { Q_ASSERT(source); D_D(DVideoWidget); source->setVideoOutput(d->formatProxy); d->player = source; } void DVideoWidget::setMirroredHorizontal(bool mirroredHorizontal) { D_D(DVideoWidget); if (d->mirroredHorizontal == mirroredHorizontal) return; d->mirroredHorizontal = mirroredHorizontal; Q_EMIT mirroredHorizontalChanged(mirroredHorizontal); } void DVideoWidget::setMirroredVertical(bool mirroredVertical) { D_D(DVideoWidget); if (d->mirroredVertical == mirroredVertical) return; d->mirroredVertical = mirroredVertical; Q_EMIT mirroredVerticalChanged(mirroredVertical); } void DVideoWidget::setScale(qreal scale) { D_D(DVideoWidget); if (d->scale == scale) return; d->scale = scale; Q_EMIT scaleChanged(scale); } void DVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) { D_D(DVideoWidget); d->aspectRatioMode = mode; } void DVideoWidget::setBrightness(int brightness) { D_D(DVideoWidget); if (d->brightness == brightness) return; d->brightness = brightness; Q_EMIT brightnessChanged(brightness); } void DVideoWidget::setContrast(int contrast) { D_D(DVideoWidget); if (d->contrast == contrast) return; d->contrast = contrast; Q_EMIT contrastChanged(contrast); } void DVideoWidget::setHue(int hue) { D_D(DVideoWidget); if (d->hue == hue) return; d->hue = hue; Q_EMIT hueChanged(hue); } void DVideoWidget::setSaturation(int saturation) { D_D(DVideoWidget); if (d->saturation == saturation) return; d->saturation = saturation; Q_EMIT saturationChanged(saturation); } void DVideoWidget::setRound(bool round) { D_D(DVideoWidget); if (d->round == round) return; d->round = round; Q_EMIT roundChanged(round); } void DVideoWidget::paintEvent(QPaintEvent *) { D_DC(DVideoWidget); QPainter painter(this); const QMediaPlaylist *pl = d->player ? d->player->playlist() : NULL; bool loop = pl && (pl->playbackMode() == QMediaPlaylist::Loop || pl->playbackMode() == QMediaPlaylist::CurrentItemInLoop); QVideoFrame frame = (!loop || d->formatProxy->m_currentFrame.isValid()) ? d->formatProxy->m_currentFrame : d->formatProxy->m_lastFrame; frame.map(QAbstractVideoBuffer::ReadOnly); QImage image( frame.bits(), frame.width(), frame.height(), QVideoFrame::imageFormatFromPixelFormat(frame.pixelFormat())); frame.unmap(); if (image.isNull()) { return; } image.setDevicePixelRatio(d->ratio); image = image.scaled(size() * d->scale * d->ratio, d->aspectRatioMode, Qt::SmoothTransformation); image = image.mirrored(d->mirroredHorizontal, d->mirroredVertical); if (d->round) { QPainterPath path; int diameter = qMin(width(), height()); path.addEllipse(width()/2.0-diameter/2.0, height()/2.0-diameter/2.0, diameter, diameter); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setClipPath(path); } painter.drawImage(QRectF(rect()).center() - QRectF(image.rect()).center() / d->ratio, image); } DWIDGET_END_NAMESPACE #include "dvideowidget.moc" dtkwidget-2.0.7.2/src/widgets/dvideowidget.h000066400000000000000000000065501325435343100207430ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DVIDEOWIDGET_H #define DVIDEOWIDGET_H #include "dtkwidget_global.h" #include "dobject.h" #include QT_BEGIN_NAMESPACE class QCamera; class QMediaPlayer; class QVideoFrame; QT_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DVideoWidgetPrivate; class LIBDTKWIDGETSHARED_EXPORT DVideoWidget : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(bool mirroredHorizontal READ mirroredHorizontal WRITE setMirroredHorizontal NOTIFY mirroredHorizontalChanged) Q_PROPERTY(bool mirroredVertical READ mirroredVertical WRITE setMirroredVertical NOTIFY mirroredVerticalChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged) Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged) Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged) Q_PROPERTY(bool round READ round WRITE setRound NOTIFY roundChanged) public: explicit DVideoWidget(QWidget *parent = 0); bool mirroredHorizontal() const; bool mirroredVertical() const; void paint(const QVideoFrame& frame); qreal scale() const; Qt::AspectRatioMode aspectRatioMode() const; void setSourceVideoPixelRatio(const qreal ratio); const qreal sourceVideoPixelRatio() const; int brightness() const; int contrast() const; int hue() const; int saturation() const; const QVideoFrame* currentFrame() const; QPixmap capture(); bool round() const; Q_SIGNALS: void mirroredHorizontalChanged(bool mirroredHorizontal); void mirroredVerticalChanged(bool mirroredVertical); void scaleChanged(qreal scale); void brightnessChanged(int brightness); void contrastChanged(int contrast); void hueChanged(int hue); void saturationChanged(int saturation); void roundChanged(bool round); public Q_SLOTS: void setSource(QCamera *source); void setSource(QMediaPlayer *source); void setMirroredHorizontal(bool mirroredHorizontal); void setMirroredVertical(bool mirroredVertical); void setScale(qreal scale); void setAspectRatioMode(Qt::AspectRatioMode mode); void setBrightness(int brightness); void setContrast(int contrast); void setHue(int hue); void setSaturation(int saturation); void setRound(bool round); protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DVideoWidget) }; DWIDGET_END_NAMESPACE #endif // DVIDEOWIDGET_H dtkwidget-2.0.7.2/src/widgets/dwaterprogress.cpp000066400000000000000000000237321325435343100216740ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dwaterprogress.h" #include #include #include #include #include #include DCORE_USE_NAMESPACE DWIDGET_BEGIN_NAMESPACE struct Pop { Pop(double s, double xs, double ys): size(s), xSpeed(xs), ySpeed(ys) {} double size; double xSpeed; double ySpeed; double xOffset; double yOffset; }; class DWaterProgressPrivate: public DTK_CORE_NAMESPACE::DObjectPrivate { public: DWaterProgressPrivate(DWaterProgress *parent): DObjectPrivate(parent) { pops.append(Pop(7, -1.8, 0.6)); pops.append(Pop(8, 1.2, 1.0)); pops.append(Pop(11, 0.8, 1.6)); } void resizePixmap(QSize sz); void initUI(); void setValue(int v); void paint(QPainter *p); QImage waterFrontImage; QImage waterBackImage; QString progressText; QTimer *timer = Q_NULLPTR; QList pops; int interval = 33; int value; double frontXOffset = 0; double backXOffset = 0; bool textVisible = true; D_DECLARE_PUBLIC(DWaterProgress) }; //! //! \brief DWaterProgress::DWaterProgress create an new water animation progress //! \param parent //! DWaterProgress::DWaterProgress(QWidget *parent) : QWidget(parent), DObject(*new DWaterProgressPrivate(this)) { D_D(DWaterProgress); d->initUI(); // apply effect auto effect = new QGraphicsDropShadowEffect(this); effect->setOffset(0, 6); effect->setColor(QColor(1, 153, 248, 255 * 5 / 20)); effect->setBlurRadius(12); this->setGraphicsEffect(effect); } //! //! \brief DWaterProgress::~DWaterProgress //! DWaterProgress::~DWaterProgress() { } //! //! \brief DWaterProgress::value //! \return return the current progress value //! int DWaterProgress::value() const { D_DC(DWaterProgress); return d->value; } //! //! \brief DWaterProgress::start will begin water movie //! void DWaterProgress::start() { D_DC(DWaterProgress); d->timer->start(); } //! //! \brief DWaterProgress::stop will stop water movie //! void DWaterProgress::stop() { D_DC(DWaterProgress); d->timer->stop(); } //! //! \brief DWaterProgress::setValue //! \param set progress value, must range 0 ~ 100 //! void DWaterProgress::setValue(int value) { D_D(DWaterProgress); if (d->value == value) { return; } d->setValue(value); Q_EMIT valueChanged(); } //! //! \brief DWaterProgress::setTextVisible //! \param set the progress text value(like 50% when value is 50) visible. //! void DWaterProgress::setTextVisible(bool visible) { D_D(DWaterProgress); d->textVisible = visible; } void DWaterProgress::paintEvent(QPaintEvent *) { D_D(DWaterProgress); QPainter p(this); d->paint(&p); } void DWaterProgressPrivate::resizePixmap(QSize sz) { // resize water; auto waterWidth = 500 * sz.width() / 100; auto waterHeight = 110 * sz.height() / 100; auto waterSize = QSizeF(waterWidth, waterHeight).toSize(); if (waterFrontImage.size() != waterSize) { DSvgRenderer renderer(QString(":/images/light/images/water_front.svg")); QImage image(waterWidth, waterHeight, QImage::Format_ARGB32); image.fill(Qt::transparent); // partly transparent red-ish background QPainter waterPainter(&image); renderer.render(&waterPainter); waterFrontImage = image; } if (waterBackImage.size() != waterSize) { DSvgRenderer renderer(QString(":/images/light/images/water_back.svg")); QImage image(waterWidth, waterHeight, QImage::Format_ARGB32); image.fill(Qt::transparent); // partly transparent red-ish background QPainter waterPainter(&image); renderer.render(&waterPainter); waterBackImage = image; } } void DWaterProgressPrivate::initUI() { D_Q(DWaterProgress); q->setMinimumSize(100, 100); value = 0; timer = new QTimer(q); timer->setInterval(interval); resizePixmap(q->size()); frontXOffset = q->width(); backXOffset = 0; q->connect(timer, &QTimer::timeout, q, [ = ] { // interval can not be zero, and limit to 1 interval = (interval < 1) ? 1 : interval; // move 60% per second double frontXDeta = 40.0 / (1000.0 / interval); // move 90% per second double backXDeta = 60.0 / (1000.0 / interval); int canvasWidth = static_cast(q->width() * q->devicePixelRatioF()); frontXOffset -= frontXDeta *canvasWidth / 100; backXOffset += backXDeta *canvasWidth / 100; if (frontXOffset > canvasWidth) { frontXOffset = canvasWidth; } if (frontXOffset < - (waterFrontImage.width() - canvasWidth)) { frontXOffset = canvasWidth; } if (backXOffset > waterBackImage.width()) { backXOffset = 0; } // update pop // move 25% per second default double speed = 25 / (1000.0 / interval) /** 100 / q->height()*/; for (auto &pop : pops) { // yOffset 0 ~ 100; pop.yOffset += speed * pop.ySpeed; if (pop.yOffset < 0) { } if (pop.yOffset > value) { pop.yOffset = 0; } pop.xOffset = qSin((pop.yOffset / 100) * 2 * 3.14) * 18 * pop.xSpeed + 50; } q->update(); }); } void DWaterProgressPrivate::setValue(int v) { value = v; progressText = QString("%1%").arg(v); } void DWaterProgressPrivate::paint(QPainter *p) { D_Q(DWaterProgress); p->setRenderHint(QPainter::Antialiasing); qreal pixelRatio = q->devicePixelRatioF(); QRectF rect = QRectF(0, 0, q->width() * pixelRatio, q->height() * pixelRatio); QSize sz = QSizeF(q->width() * pixelRatio, q->height() * pixelRatio).toSize(); resizePixmap(sz); int yOffset = rect.toRect().topLeft().y() + (100 - value - 10) * sz.height() / 100; // draw water QImage waterImage = QImage(sz, QImage::Format_ARGB32_Premultiplied); QPainter waterPinter(&waterImage); waterPinter.setRenderHint(QPainter::Antialiasing); waterPinter.setCompositionMode(QPainter::CompositionMode_Source); waterPinter.fillRect(waterImage.rect(), QColor(43, 146, 255, 255 * 3 / 10)); waterPinter.setCompositionMode(QPainter::CompositionMode_SourceOver); waterPinter.drawImage(static_cast(backXOffset), yOffset, waterBackImage); waterPinter.drawImage(static_cast(backXOffset) - waterBackImage.width(), yOffset, waterBackImage); waterPinter.drawImage(static_cast(frontXOffset), yOffset, waterFrontImage); waterPinter.drawImage(static_cast(frontXOffset) - waterFrontImage.width(), yOffset, waterFrontImage); //drwa pop if (value > 30) { for (auto &pop : pops) { QPainterPath popPath; popPath.addEllipse(pop.xOffset * sz.width() / 100, (100 - pop.yOffset) * sz.height() / 100, pop.size * sz.width() / 100, pop.size * sz.height() / 100); waterPinter.fillPath(popPath, QColor(77, 208, 255)); } } double borderWidth = 2.0 * sz.width() / 100.0; auto outRect = QRectF(0, 0, sz.width(), sz.height()); QPainterPath pathBorder; auto factor = 0.5; auto margin = QMarginsF(borderWidth * factor, borderWidth * factor, borderWidth * factor, borderWidth * factor); pathBorder.addEllipse(outRect.marginsRemoved(margin)); waterPinter.strokePath(pathBorder, QPen(QColor(43, 146, 255, 255 * 7 / 10), borderWidth)); QPainterPath pathInnerBorder; auto interFactor = 1.5; auto innerMargin = QMarginsF(borderWidth * interFactor, borderWidth * interFactor, borderWidth * interFactor, borderWidth * interFactor); pathInnerBorder.addEllipse(outRect.marginsRemoved(innerMargin)); waterPinter.strokePath(pathInnerBorder, QPen(QColor(234, 242, 255, 255 * 5 / 10), borderWidth)); if (textVisible) { auto font = waterPinter.font(); font.setPixelSize(sz.height() * 20 / 100); waterPinter.setFont(font); waterPinter.setPen(Qt::white); waterPinter.drawText(rect, Qt::AlignCenter, progressText); } waterPinter.end(); QPixmap maskPixmap(sz); maskPixmap.fill(Qt::transparent); QPainterPath path; path.addEllipse(QRectF(0, 0, sz.width(), sz.height())); QPainter maskPainter(&maskPixmap); maskPainter.setRenderHint(QPainter::Antialiasing); maskPainter.setPen(QPen(Qt::white, 1)); maskPainter.fillPath(path, QBrush(Qt::white)); QPainter::CompositionMode mode = QPainter::CompositionMode_SourceIn; QImage contentImage = QImage(sz, QImage::Format_ARGB32_Premultiplied); QPainter contentPainter(&contentImage); contentPainter.setCompositionMode(QPainter::CompositionMode_Source); contentPainter.fillRect(contentImage.rect(), Qt::transparent); contentPainter.setCompositionMode(QPainter::CompositionMode_SourceOver); contentPainter.drawImage(0, 0, maskPixmap.toImage()); contentPainter.setCompositionMode(mode); contentPainter.drawImage(0, 0, waterImage); contentPainter.setCompositionMode(QPainter::CompositionMode_DestinationOver); contentPainter.end(); contentImage.setDevicePixelRatio(pixelRatio); p->drawImage(q->rect(), contentImage); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dwaterprogress.h000066400000000000000000000027551325435343100213430ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWATERPROGRESS_H #define DWATERPROGRESS_H #include "dtkwidget_global.h" #include "dobject.h" #include #include DWIDGET_BEGIN_NAMESPACE class DWaterProgressPrivate; class LIBDTKWIDGETSHARED_EXPORT DWaterProgress : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) public: explicit DWaterProgress(QWidget *parent = 0); ~DWaterProgress(); int value() const; Q_SIGNALS: void valueChanged(); public Q_SLOTS: void start(); void stop(); void setValue(int value); void setTextVisible(bool visible); protected: void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; private: D_DECLARE_PRIVATE(DWaterProgress) }; DWIDGET_END_NAMESPACE #endif // DWATERPROGRESS_H dtkwidget-2.0.7.2/src/widgets/dwidget.cpp000066400000000000000000000020171325435343100202410ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dwidget.h" #include "private/dwidget_p.h" DWIDGET_BEGIN_NAMESPACE DWidgetPrivate::DWidgetPrivate(DWidget *q) : DX11WidgetPrivate(q) { } DWidget::DWidget(QWidget *parent): DWidget(*(new DWidgetPrivate(this)), parent) { } DWidget::DWidget(DWidgetPrivate &dd, QWidget *parent): DX11Widget(dd, parent) { } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dwidget.h000066400000000000000000000022401325435343100177040ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWIDGET_H #define DWIDGET_H #include #include #include #include "dx11widget.h" DWIDGET_BEGIN_NAMESPACE class DWidgetPrivate; class LIBDTKWIDGETSHARED_EXPORT DWidget : public DX11Widget { Q_OBJECT public: explicit DWidget(QWidget *parent = 0); explicit DWidget(DWidgetPrivate &dd, QWidget *parent = 0); private: D_DECLARE_PRIVATE(DWidget) Q_DISABLE_COPY(DWidget) }; DWIDGET_END_NAMESPACE #endif // DWIDGET_H dtkwidget-2.0.7.2/src/widgets/dwindow.cpp000066400000000000000000000041411325435343100202650ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dwindow.h" #include #include #include #include #include "dtitlebar.h" #include "private/dwidget_p.h" DWIDGET_BEGIN_NAMESPACE class DWindowPrivate: public DWidgetPrivate { D_DECLARE_PUBLIC(DWindow) public: explicit DWindowPrivate(DWindow *q); void init(); QMenu *m_menu = nullptr; QWidget *m_parent = nullptr; }; DWindowPrivate::DWindowPrivate(DWindow *q): DWidgetPrivate(q) { } void DWindowPrivate::init() { D_Q(DWindow); m_menu = new QMenu(q); q->setTitlebarMenu(m_menu); const DApplication *dapp = qobject_cast(qApp); if (dapp) { q->setWindowTitle(dapp->productName()); } else { q->setWindowTitle(qApp->applicationDisplayName()); } } DWindow::DWindow(QWidget *parent): DWidget(*(new DWindowPrivate(this))) { D_D(DWindow); setParent(parent); d->init(); } void DWindow::setParent(QWidget *parent) { D_D(DWindow); d->m_parent = parent; QObject::setParent(parent); } QWidget *DWindow::parentWidget() const { D_DC(DWindow); return d->m_parent; } void DWindow::setContentLayout(QLayout *l) { DWidget::setLayout(l); } void DWindow::setContentWidget(QWidget *w) { QHBoxLayout *l = new QHBoxLayout; l->setSpacing(0); l->setMargin(0); l->addWidget(w); l->setAlignment(w, Qt::AlignCenter); setContentLayout(l); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dwindow.h000066400000000000000000000024521325435343100177350ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWINDOW_H #define DWINDOW_H #include #include #include #include "dwidget.h" class QMenu; DWIDGET_BEGIN_NAMESPACE class DWindowPrivate; class D_DECL_DEPRECATED_X("Use DMainWindow instead.") DWindow : public DWidget { Q_OBJECT public: explicit DWindow(QWidget *parent = 0); void setContentLayout(QLayout *l); void setContentWidget(QWidget *w); void setParent(QWidget *parent); QWidget *parentWidget() const; protected Q_SLOTS: private: D_DECLARE_PRIVATE(DWindow) Q_DISABLE_COPY(DWindow) }; DWIDGET_END_NAMESPACE #endif // DWINDOW_H dtkwidget-2.0.7.2/src/widgets/dwindowclosebutton.cpp000066400000000000000000000022601325435343100225470ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dthememanager.h" #include "dwindowclosebutton.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DWindowCloseButton * \brief The DWindowCloseButton class is used as the unified window close button. * * It's actually a special DImageButton which has the appearance of close button. */ DWindowCloseButton::DWindowCloseButton(QWidget * parent) : DImageButton(parent) { DThemeManager::registerWidget(this); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dwindowclosebutton.h000066400000000000000000000017601325435343100222200ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWINDOWCLOSEBUTTON_H #define DWINDOWCLOSEBUTTON_H #include "dimagebutton.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DWindowCloseButton : public DImageButton { Q_OBJECT public: DWindowCloseButton(QWidget * parent = 0); }; DWIDGET_END_NAMESPACE #endif // DWINDOWCLOSEBUTTON_H dtkwidget-2.0.7.2/src/widgets/dwindowmaxbutton.cpp000066400000000000000000000040651325435343100222340ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "dthememanager.h" #include "dwindowmaxbutton.h" #include "private/dimagebutton_p.h" #include DWIDGET_BEGIN_NAMESPACE class DWindowMaxButtonPrivate : public DImageButtonPrivate{ public: DWindowMaxButtonPrivate(DWindowMaxButton* qq):DImageButtonPrivate(qq) { m_isMaximized = false; } private: bool m_isMaximized; Q_DECLARE_PUBLIC(DWindowMaxButton) }; /*! * \class DWindowMaxButton * \brief The DWindowMaxButton class is used as the unified window maximize button. * * It's actually a special DImageButton which has the appearance of maximize button. */ DWindowMaxButton::DWindowMaxButton(QWidget * parent) : DImageButton(*new DWindowMaxButtonPrivate(this), parent) { DThemeManager::registerWidget(this, QStringList({"isMaximized"})); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); } /*! * \property isMaximized * \brief isMaximized indicates whether the button state is maximized or not. * * It's true if it's set to maximized, otherwise false. */ bool DWindowMaxButton::isMaximized() const { D_DC(DWindowMaxButton); return d->m_isMaximized; } void DWindowMaxButton::setMaximized(bool isMaximized) { D_D(DWindowMaxButton); if (d->m_isMaximized == isMaximized) return; d->m_isMaximized = isMaximized; Q_EMIT maximizedChanged(isMaximized); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dwindowmaxbutton.h000066400000000000000000000024761325435343100217050ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWINDOWMAXBUTTON_H #define DWINDOWMAXBUTTON_H #include #include "dimagebutton.h" DWIDGET_BEGIN_NAMESPACE class DWindowMaxButtonPrivate; class LIBDTKWIDGETSHARED_EXPORT DWindowMaxButton : public DImageButton { Q_OBJECT public: DWindowMaxButton(QWidget * parent = 0); Q_PROPERTY(bool isMaximized READ isMaximized WRITE setMaximized NOTIFY maximizedChanged) bool isMaximized() const; public Q_SLOTS: void setMaximized(bool isMaximized); Q_SIGNALS: void maximizedChanged(bool isMaximized); private: D_DECLARE_PRIVATE(DWindowMaxButton) }; DWIDGET_END_NAMESPACE #endif // DWINDOWMAXBUTTON_H dtkwidget-2.0.7.2/src/widgets/dwindowminbutton.cpp000066400000000000000000000022541325435343100222300ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dthememanager.h" #include "dwindowminbutton.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DWindowMinButton * \brief The DWindowMinButton class is used as the unified window minimize button. * * It's actually a special DImageButton which has the appearance of minimize button. */ DWindowMinButton::DWindowMinButton(QWidget * parent) : DImageButton(parent) { DThemeManager::registerWidget(this); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dwindowminbutton.h000066400000000000000000000017461325435343100217020ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWINDOWMINBUTTON_H #define DWINDOWMINBUTTON_H #include "dimagebutton.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DWindowMinButton : public DImageButton { Q_OBJECT public: DWindowMinButton(QWidget * parent = 0); }; DWIDGET_END_NAMESPACE #endif // DWINDOWMINBUTTON_H dtkwidget-2.0.7.2/src/widgets/dwindowoptionbutton.cpp000066400000000000000000000022711325435343100227540ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dthememanager.h" #include "dwindowoptionbutton.h" DWIDGET_BEGIN_NAMESPACE /*! * \class DWindowOptionButton * \brief The DWindowOptionButton class is used as the unified window option button. * * It's actually a special DImageButton which has the appearance of option button. */ DWindowOptionButton::DWindowOptionButton(QWidget * parent) : DImageButton(parent) { DThemeManager::registerWidget(this); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dwindowoptionbutton.h000066400000000000000000000017651325435343100224300ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWINDOWOPTIONBUTTON_H #define DWINDOWOPTIONBUTTON_H #include "dimagebutton.h" DWIDGET_BEGIN_NAMESPACE class LIBDTKWIDGETSHARED_EXPORT DWindowOptionButton : public DImageButton { Q_OBJECT public: DWindowOptionButton(QWidget * parent = 0); }; DWIDGET_END_NAMESPACE #endif // DWINDOWOPTIONBUTTON_H dtkwidget-2.0.7.2/src/widgets/dwindowrestorebutton.cpp000066400000000000000000000016571325435343100231360ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dthememanager.h" #include "dwindowrestorebutton.h" DWIDGET_BEGIN_NAMESPACE DWindowRestoreButton::DWindowRestoreButton(QWidget * parent) : DImageButton(parent) { DThemeManager::registerWidget(this); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/dwindowrestorebutton.h000066400000000000000000000021321325435343100225700ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWINDOWRESTOREBUTTON_H #define DWINDOWRESTOREBUTTON_H #include #include #include "dimagebutton.h" DWIDGET_BEGIN_NAMESPACE class D_DECL_DEPRECATED_X("DWindowMaxButton is sufficient representing the two states.") DWindowRestoreButton : public DImageButton { Q_OBJECT public: DWindowRestoreButton(QWidget * parent = 0); }; DWIDGET_END_NAMESPACE #endif // DWINDOWRESTOREBUTTON_H dtkwidget-2.0.7.2/src/widgets/dx11widget.cpp000066400000000000000000000504621325435343100206020ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dx11widget.h" #include #include #include #include #include #include #include #include #include #include #include #include "dtitlebar.h" #include "private/dwidget_p.h" #ifdef Q_OS_LINUX #include "../platforms/x11/xutil.h" #endif #include "dwidgetutil.h" DWIDGET_BEGIN_NAMESPACE const int WindowGlowRadius = 40; const int WindowRadius = 4; const int WindowBorder = 1; const int WindowHandleWidth = 10; const QColor BorderColor = QColor(0, 0, 0, 60); const QColor BackgroundTopColor = QColor(255, 255, 255); const QColor BackgroundBottonColor = QColor(255, 255, 255); const QColor TipsBorderColor = QColor(255, 255, 255, 255 * 0.2); const QColor TipsBackground = QColor(0, 0, 0); /// shadow #define SHADOW_COLOR_NORMAL QColor(0, 0, 0, 255 * 0.15) #define SHADOW_COLOR_ACTIVE QColor(0, 0, 0, 255 * 0.3) DX11WidgetPrivate::DX11WidgetPrivate(DX11Widget *q) : DObjectPrivate(q) { leftPressed = false; resizable = true; } void DX11WidgetPrivate::init() { D_Q(DX11Widget); dwindowFlags = Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint; m_NormalShadowWidth = WindowGlowRadius; m_ShadowWidth = WindowGlowRadius; shadowColor = SHADOW_COLOR_ACTIVE; shadowOffset = QPoint(0, 10); m_Radius = WindowRadius; m_Border = WindowBorder; m_ResizeHandleWidth = WindowHandleWidth; m_MousePressed = false; m_backgroundColor = BackgroundTopColor; rootLayout = new QVBoxLayout(q); rootLayout->setSpacing(0); updateContentsMargins(); windowWidget = new QWidget; QVBoxLayout *windowLayout = new QVBoxLayout(windowWidget); windowLayout->setMargin(0); windowLayout->setSpacing(0); rootLayout->addWidget(windowWidget); titlebar = new DTitlebar; contentWidget = new QWidget; QVBoxLayout *contentWidgetLayout = new QVBoxLayout; contentWidgetLayout->setSpacing(0); contentWidgetLayout->setMargin(0); contentWidget->setLayout(contentWidgetLayout); contentWidget->setContentsMargins(m_Border, 0, m_Border, m_Border); contentWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); windowLayout->addWidget(titlebar); windowLayout->addWidget(contentWidget); auto filter = new FilterMouseMove(windowWidget); windowWidget->installEventFilter(filter); filter->m_rootWidget = q; q->connect(titlebar, &DTitlebar::optionClicked, q, &DX11Widget::optionClicked); q->connect(titlebar, &DTitlebar::mouseMoving, q, &DX11Widget::moveWindow); q->connect(titlebar, SIGNAL(mousePressed(Qt::MouseButtons)), q, SLOT(_q_onTitleBarMousePressed(Qt::MouseButtons))); q->connect(qApp, &QGuiApplication::focusWindowChanged, q, [q] { if (q->isActiveWindow()) { q->setShadowColor(SHADOW_COLOR_ACTIVE); } else { q->setShadowColor(SHADOW_COLOR_NORMAL); } }); } QSize DX11WidgetPrivate::externSize(const QSize &size) const { return QSize(size.width() + (m_ShadowWidth + m_Border) * 2, size.height() + (m_ShadowWidth + m_Border) * 2); } QMargins DX11WidgetPrivate::externMargins() const { return rootLayout->contentsMargins() + contentWidget->contentsMargins(); } int DX11WidgetPrivate::externWidth() const { return m_ShadowWidth + m_Border; } void DX11WidgetPrivate::updateContentsMargins() { rootLayout->setContentsMargins(m_ShadowWidth + m_Border - shadowOffset.x(), m_ShadowWidth + m_Border - shadowOffset.y(), m_ShadowWidth + m_Border + shadowOffset.x(), m_ShadowWidth + m_Border + shadowOffset.y()); } void DX11WidgetPrivate::_q_onTitleBarMousePressed(Qt::MouseButtons buttons) const { #ifdef Q_OS_LINUX D_QC(DX11Widget); if (buttons != Qt::LeftButton) { XUtils::CancelMoveWindow(q, Qt::LeftButton); } #else Q_UNUSED(buttons); #endif } DX11Widget::DX11Widget(QWidget *parent): DX11Widget(*new DX11WidgetPrivate(this), parent) { } DX11Widget::DecorationFlags DX11Widget::decorationFlags() { D_D(DX11Widget); return d->decorationFlags; } void DX11Widget::setDecorationFlags(DX11Widget::DecorationFlags flags) { D_D(DX11Widget); d->decorationFlags = flags; if (flags & ShowTitlebarSeparator) { d->titlebar->setSeparatorVisible(true); } else { d->titlebar->setSeparatorVisible(false); } } DX11Widget::DX11Widget(DX11WidgetPrivate &dd, QWidget *parent) : QWidget(parent), DObject(dd) { D_D(DX11Widget); d->init(); QWidget::setMouseTracking(true); QWidget::setAttribute(Qt::WA_TranslucentBackground, true); QWidget::setWindowFlags(Qt::Window | Qt::FramelessWindowHint); setWindowFlags(windowFlags()); setDecorationFlags(decorationFlags()); DX11Widget::adjustSize(); #ifdef Q_OS_LINUX XUtils::SetMouseTransparent(this, true); #endif #ifdef DTK_TITLE_DRAG_WINDOW connect(d->titlebar, &DTitlebar::mousePosMoving, this, [ = ](Qt::MouseButton /*botton*/, QPoint pos) { move(pos - d->m_LastMousePos); }); connect(d->titlebar, &DTitlebar::mousePosPressed, this, [ = ](Qt::MouseButtons /*botton*/, QPoint pos) { // TODO: fix margin pos.setY(pos.y() - 10); d->m_LastMousePos = pos - this->mapToParent(this->pos()); }); #endif } void DX11Widget::enterEvent(QEvent *e) { // qDebug() << "enterEvent" ; return QWidget::enterEvent(e); } void DX11Widget::leaveEvent(QEvent *e) { // qDebug() << "leaveEvent"; return QWidget::leaveEvent(e); } void DX11Widget::changeEvent(QEvent *event) { D_D(DX11Widget); if (event->type() == QEvent::WindowStateChange) { d->updateContentsMargins(); } QWidget::changeEvent(event); } void DX11Widget::mouseMoveEvent(QMouseEvent *event) { #ifdef Q_OS_LINUX D_D(DX11Widget); const int x = event->x(); const int y = event->y(); if (d->resizingCornerEdge == XUtils::CornerEdge::kInvalid && d->resizable) { XUtils::UpdateCursorShape(this, x, y, d->externMargins(), d->m_ResizeHandleWidth); } #endif return QWidget::mouseMoveEvent(event); } void DX11Widget::mousePressEvent(QMouseEvent *event) { #ifdef Q_OS_LINUX D_D(DX11Widget); const int x = event->x(); const int y = event->y(); if (event->button() == Qt::LeftButton) { const XUtils::CornerEdge ce = XUtils::GetCornerEdge(this, x, y, d->externMargins(), d->m_ResizeHandleWidth); if (ce != XUtils::CornerEdge::kInvalid) { d->resizingCornerEdge = ce; XUtils::StartResizing(this, QCursor::pos(), ce); } } #endif return QWidget::mousePressEvent(event); } void DX11Widget::mouseReleaseEvent(QMouseEvent *event) { #ifdef Q_OS_LINUX D_D(DX11Widget); d->resizingCornerEdge = XUtils::CornerEdge::kInvalid; #endif return QWidget::mouseReleaseEvent(event); } void DX11Widget::showMinimized() { #ifdef Q_OS_LINUX XUtils::ShowMinimizedWindow(this, true); #endif QWidget::showMinimized(); } void DX11Widget::showMaximized() { #ifdef Q_OS_LINUX XUtils::ShowMaximizedWindow(this); #endif this->show(); this->activateWindow(); this->raise(); } void DX11Widget::setContentsMargins(int left, int top, int right, int bottom) { D_D(DX11Widget); d->contentWidget->setContentsMargins(left, top, right, bottom); } void DX11Widget::setContentsMargins(const QMargins &margins) { D_D(DX11Widget); d->contentWidget->setContentsMargins(margins); } void DX11Widget::getContentsMargins(int *left, int *top, int *right, int *bottom) const { D_DC(DX11Widget); d->contentWidget->getContentsMargins(left, top, right, bottom); } QMargins DX11Widget::contentsMargins() const { D_DC(DX11Widget); return d->contentWidget->contentsMargins(); } void DX11Widget::showFullScreen() { #ifdef Q_OS_LINUX XUtils::ShowFullscreenWindow(this, true); #endif this->show(); this->activateWindow(); this->raise(); } void DX11Widget::moveWindow(Qt::MouseButton botton) { #ifdef Q_OS_LINUX XUtils::MoveWindow(this, botton); #endif } void DX11Widget::toggleMaximizedWindow() { #ifdef Q_OS_LINUX XUtils::ToggleMaximizedWindow(this); #endif } void DX11Widget::showNormal() { #ifdef Q_OS_LINUX XUtils::ShowNormalWindow(this); #endif } void DX11Widget::removeLayout() { qDeleteAll(this->children()); } Qt::WindowFlags DX11Widget::windowFlags() { D_D(DX11Widget); return d->dwindowFlags; } /// /// \brief setWindowFlags /// \param type /// void DX11Widget::setWindowFlags(Qt::WindowFlags type) { D_D(DX11Widget); d->dwindowFlags = type; d->titlebar->setWindowFlags(type); } int DX11Widget::titlebarHeight() const { D_DC(DX11Widget); return d->titlebar->height(); } void DX11Widget::setTitlebarFixedHeight(int h) { D_D(DX11Widget); d->titlebar->setFixedHeight(h); DX11Widget::adjustSize(); } void DX11Widget::setTitle(const QString &t) { D_D(DX11Widget); d->titlebar->setTitle(t); } void DX11Widget::setTitleIcon(const QPixmap &icon) { D_D(DX11Widget); d->titlebar->setIcon(icon); } DTitlebar *DX11Widget::titlebar() const { D_DC(DX11Widget); return d->titlebar; } void DX11Widget::setTitlebarMenu(QMenu *menu) { D_D(DX11Widget); d->titlebar->setMenu(menu); } QMenu *DX11Widget::titleBarMenu() const { D_DC(DX11Widget); return d->titlebar->menu(); } void DX11Widget::setTitlebarWidget(QWidget *w, bool fixCenterPos) { D_D(DX11Widget); d->titlebar->setCustomWidget(w, Qt::AlignCenter, fixCenterPos); } void DX11Widget::setTitlebarWidget(QWidget *w, Qt::AlignmentFlag wflag, bool fixCenterPos) { D_D(DX11Widget); d->titlebar->setCustomWidget(w, wflag, fixCenterPos); } // TODO: fix layout QLayout *DX11Widget::layout() const { D_DC(DX11Widget); return d->contentWidget->layout(); } void DX11Widget::setLayout(QLayout *l) { D_D(DX11Widget); qDeleteAll(d->contentWidget->children()); d->contentWidget->setLayout(l); d->contentWidget->adjustSize(); d->windowWidget->adjustSize(); DX11Widget::resize(d->windowWidget->size()); } int DX11Widget::radius() const { D_DC(DX11Widget); return d->m_Radius; } void DX11Widget::setRadius(int r) { D_D(DX11Widget); if (r > d->m_Border * 2) { r = d->m_Border * 2; } d->m_Radius = r; } int DX11Widget::shadowWidth() const { D_DC(DX11Widget); return d->m_Radius; } void DX11Widget::setShadowWidth(int r) { D_D(DX11Widget); if (d->m_ShadowWidth == r) { return; } d->m_Radius = r; d->m_ShadowWidth = r; d->updateContentsMargins(); drawShadowPixmap(); update(); } QColor DX11Widget::backgroundColor() const { D_DC(DX11Widget); return d->m_backgroundColor; } QColor DX11Widget::shadowColor() const { D_DC(DX11Widget); return d->shadowColor; } QPoint DX11Widget::shadowOffset() const { D_DC(DX11Widget); return d->shadowOffset; } void DX11Widget::setBackgroundColor(QColor backgroundColor) { D_D(DX11Widget); if (d->m_backgroundColor == backgroundColor) { return; } d->m_backgroundColor = backgroundColor; Q_EMIT backgroundColorChanged(backgroundColor); } void DX11Widget::setShadowColor(QColor shadowColor) { D_D(DX11Widget); if (d->shadowColor == shadowColor) { return; } d->shadowColor = shadowColor; drawShadowPixmap(); update(); Q_EMIT shadowColorChanged(shadowColor); } void DX11Widget::setShadowOffset(QPoint shadowOffset) { D_D(DX11Widget); if (d->shadowOffset == shadowOffset) { return; } d->shadowOffset = shadowOffset; d->updateContentsMargins(); update(); Q_EMIT shadowOffsetChanged(shadowOffset); } void DX11Widget::drawShadowPixmap() { D_D(DX11Widget); QPixmap pixmap(QWidget::size() - QSize(d->m_ShadowWidth * 2, d->m_ShadowWidth * 2)); pixmap.fill(Qt::black); d->shadowPixmap = QPixmap::fromImage(Dtk::Widget::dropShadow(pixmap, d->m_ShadowWidth, d->shadowColor)); } int DX11Widget::border() const { D_DC(DX11Widget); return d->m_Border; } void DX11Widget::setBorder(int b) { D_D(DX11Widget); if (b < 0) { b = 0; } d->m_Border = b; if (d->m_Radius > b * 2) { d->m_Radius = b * 2; } } const QPixmap &DX11Widget::backgroundImage() const { D_DC(DX11Widget); return d->m_Background; } void DX11Widget::setBackgroundImage(const QPixmap &srcPixmap) { D_D(DX11Widget); int radius = d->m_Radius; int windowExtern = d->m_ShadowWidth + d->m_Border * 2; QRect windowRect = QWidget::rect().marginsRemoved( QMargins(windowExtern, windowExtern, windowExtern, windowExtern)); QSize sz = windowRect.size(); QPixmap backgroundPixmap = srcPixmap.scaled(sz, Qt::KeepAspectRatioByExpanding); QPixmap maskPixmap(sz); maskPixmap.fill(Qt::transparent); QPainterPath path; path.addRoundRect(QRectF(0, 0, sz.width(), sz.height()), radius / 2); QPainter bkPainter(&maskPixmap); bkPainter.setRenderHint(QPainter::Antialiasing); bkPainter.setPen(QPen(Qt::white, 1)); bkPainter.fillPath(path, QBrush(Qt::red)); QPainter::CompositionMode mode = QPainter::CompositionMode_SourceIn; QImage resultImage = QImage(sz, QImage::Format_ARGB32_Premultiplied); QPainter painter(&resultImage); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(resultImage.rect(), Qt::transparent); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.drawImage(0, 0, maskPixmap.toImage()); painter.setCompositionMode(mode); painter.drawImage(0, 0, backgroundPixmap.toImage()); painter.setCompositionMode(QPainter::CompositionMode_DestinationOver); painter.end(); d->m_Background = QPixmap::fromImage(resultImage); } void DX11Widget::setFixedSize(const QSize &size) { D_D(DX11Widget); d->resizable = false; d->titlebar->setMinimumWidth(size.width()); d->windowWidget->setFixedSize(size); d->contentWidget->setFixedSize(size.width(), size.height() - titlebarHeight()); QSize externSize = d->externSize(size); QWidget::setFixedSize(externSize); setWindowFlags(windowFlags() & ~ Qt::WindowMaximizeButtonHint); #ifdef Q_OS_LINUX XUtils::DisableResize(this); #endif } void DX11Widget::setFixedSize(int w, int h) { DX11Widget::setFixedSize(QSize(w, h)); } void DX11Widget::setFixedWidth(int w) { D_D(DX11Widget); d->titlebar->setFixedWidth(w); d->windowWidget->setFixedWidth(w); QWidget::setFixedWidth(w + d->m_ShadowWidth + d->m_Border); } void DX11Widget::resize(int width, int height) { resize(QSize(width, height)); } void DX11Widget::resize(const QSize &size) { D_D(DX11Widget); d->windowWidget->resize(size); d->titlebar->resize(size.width(), d->titlebar->height()); QSize externSize = d->externSize(size); if (d->resizable) { QWidget::setMinimumSize(externSize); QWidget::resize(externSize); } else { QWidget::setMaximumSize(externSize); } } void DX11Widget::adjustSize() { D_D(DX11Widget); d->windowWidget->adjustSize(); QSize externSize = d->externSize(d->windowWidget->size()); if (d->resizable) { QWidget::setMinimumSize(externSize); QWidget::resize(externSize); } else { QWidget::setMaximumSize(externSize); QWidget::resize(externSize); } } QSize DX11Widget::size() const { D_DC(DX11Widget); return d->windowWidget->size(); } void DX11Widget::move(int x, int y) { D_D(DX11Widget); QWidget::move(x - d->externWidth(), y - d->externWidth()); } void DX11Widget::move(const QPoint &p) { DX11Widget::move(p.x(), p.y()); } QRect DX11Widget::frameGeometry() const { D_DC(DX11Widget); return d->windowWidget->frameGeometry(); } const QRect &DX11Widget::geometry() const { D_DC(DX11Widget); return d->windowWidget->geometry(); } QRect DX11Widget::normalGeometry() const { D_DC(DX11Widget); return d->windowWidget->normalGeometry(); } int DX11Widget::x() const { D_DC(DX11Widget); return d->windowWidget->x(); } int DX11Widget::y() const { D_DC(DX11Widget); return d->windowWidget->y(); } QPoint DX11Widget::pos() const { D_DC(DX11Widget); return d->windowWidget->pos(); } QSize DX11Widget::frameSize() const { D_DC(DX11Widget); return d->windowWidget->frameSize(); } int DX11Widget::width() const { D_DC(DX11Widget); return d->windowWidget->width(); } int DX11Widget::height() const { D_DC(DX11Widget); return d->windowWidget->height(); } inline QRect DX11Widget::rect() const { D_DC(DX11Widget); return d->windowWidget->rect(); } QRect DX11Widget::childrenRect() const { D_DC(DX11Widget); return d->windowWidget->childrenRect(); } QRegion DX11Widget::childrenRegion() const { D_DC(DX11Widget); return d->windowWidget->childrenRegion(); } void DX11Widget::showEvent(QShowEvent *e) { QWidget::showEvent(e); } void DX11Widget::resizeEvent(QResizeEvent *e) { D_D(DX11Widget); #ifdef Q_OS_LINUX int resizeHandleWidth = d->resizable ? d->m_ResizeHandleWidth : 0; XUtils::SetWindowExtents(this, d->externMargins(), resizeHandleWidth); #endif drawShadowPixmap(); d->titlebar->resize(e->size().width(), d->titlebar->height()); QWidget::resizeEvent(e); } void DX11Widget::closeEvent(QCloseEvent *e) { QWidget::closeEvent(e); } void DX11Widget::paintEvent(QPaintEvent * /*e*/) { D_D(DX11Widget); int radius = d->m_Radius; //. TODO: border not part of window? int windowExtern = d->m_ShadowWidth + d->m_Border * 2; int contentExtern = d->m_ShadowWidth + d->m_Border * 2; QPainter painter(this); painter.drawPixmap(0, 0, d->shadowPixmap); QRect contentRect = QWidget::rect().marginsRemoved(QMargins(contentExtern, contentExtern, contentExtern, contentExtern)); QRect windowRect = QWidget::rect().marginsRemoved(QMargins(windowExtern, windowExtern, windowExtern, windowExtern)); contentRect.moveTopLeft(contentRect.topLeft() - d->shadowOffset); windowRect.moveTopLeft(windowRect.topLeft() - d->shadowOffset); if (! d->m_Background.isNull()) { painter.drawPixmap(contentRect, d->m_Background); } else { QPoint topLeft(windowRect.x(), windowRect.y()); QPoint bottomRight(windowRect.x() + windowRect.width(), windowRect.y() + windowRect.height()); QPainterPath border; border.addRoundedRect(windowRect, radius, radius); QLinearGradient linearGradient(topLeft, QPoint(topLeft.x(), bottomRight.y())); linearGradient.setColorAt(0.0, d->m_backgroundColor); linearGradient.setColorAt(0.2, d->m_backgroundColor); linearGradient.setColorAt(1.0, d->m_backgroundColor); QPen borderPen(BorderColor); painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(QBrush(linearGradient)); painter.strokePath(border, borderPen); painter.fillPath(border, /*palette().background()*/QBrush(linearGradient)); } } FilterMouseMove::FilterMouseMove(QObject *object) : QObject(object) { } FilterMouseMove::~FilterMouseMove() { } bool FilterMouseMove::eventFilter(QObject *obj, QEvent *event) { switch (event->type()) { case QEvent::Enter: { if (qobject_cast(obj) != qobject_cast(this->parent())) { break; } if (m_rootWidget) { #ifdef Q_OS_LINUX XUtils::ResetCursorShape(m_rootWidget); #endif } break; } default: { } } return QObject::eventFilter(obj, event); } DWIDGET_END_NAMESPACE #include "moc_dx11widget.cpp" dtkwidget-2.0.7.2/src/widgets/dx11widget.h000066400000000000000000000135041325435343100202430ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DABSTRACTWIDGET_H #define DABSTRACTWIDGET_H #include #include #include class QMenu; DWIDGET_BEGIN_NAMESPACE class DX11WidgetPrivate; class DTitlebar; class LIBDTKWIDGETSHARED_EXPORT DX11Widget : public QWidget, public DTK_CORE_NAMESPACE::DObject { Q_OBJECT public: enum DecorationFlag { ShowTitlebarSeparator = 0x01 }; Q_DECLARE_FLAGS(DecorationFlags, DecorationFlag) Q_FLAGS(DecorationFlags) explicit DX11Widget(QWidget *parent = 0); Q_PROPERTY(int radius READ radius WRITE setRadius) Q_PROPERTY(int shadowWidth READ shadowWidth WRITE setShadowWidth) Q_PROPERTY(int border READ border WRITE setBorder) Q_PROPERTY(int titlebarHeight READ titlebarHeight WRITE setTitlebarFixedHeight) Q_PROPERTY(QPixmap backgroundImage READ backgroundImage WRITE setBackgroundImage) Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged) Q_PROPERTY(QPoint shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged) DecorationFlags decorationFlags(); void setDecorationFlags(DecorationFlags flags); Qt::WindowFlags windowFlags(); void setWindowFlags(Qt::WindowFlags type); void setTitle(const QString &); void setTitleIcon(const QPixmap &icon); DTitlebar *titlebar() const; void setTitlebarMenu(QMenu *); QMenu *titleBarMenu() const; void setTitlebarWidget(QWidget *, bool fixCenterPos = false); void setTitlebarWidget(QWidget *w, Qt::AlignmentFlag wflag, bool fixCenterPos = false); int titlebarHeight() const; void setTitlebarFixedHeight(int h); QLayout *layout() const; void setLayout(QLayout *); int radius() const; void setRadius(int r); int shadowWidth() const; void setShadowWidth(int w); int border() const; void setBorder(int b); const QPixmap &backgroundImage() const; void setBackgroundImage(const QPixmap &srcPixmap); void setContentsMargins(int left, int top, int right, int bottom); void setContentsMargins(const QMargins &margins); void getContentsMargins(int *left, int *top, int *right, int *bottom) const; QMargins contentsMargins() const; void setFixedSize(const QSize &); void setFixedSize(int w, int h); void setFixedWidth(int w); // void setFixedHeight(int h); void resize(int width, int height); void resize(const QSize &); void removeLayout(); void adjustSize(); void move(int x, int y); void move(const QPoint &); QRect frameGeometry() const; const QRect &geometry() const; QRect normalGeometry() const; int x() const; int y() const; QPoint pos() const; QSize frameSize() const; QSize size() const; int width() const; int height() const; QRect rect() const; QRect childrenRect() const; QRegion childrenRegion() const; QSize minimumSize() const; QSize maximumSize() const; int minimumWidth() const; int minimumHeight() const; int maximumWidth() const; int maximumHeight() const; void setMinimumSize(const QSize &); void setMinimumSize(int minw, int minh); void setMaximumSize(const QSize &); void setMaximumSize(int maxw, int maxh); void setMinimumWidth(int minw); void setMinimumHeight(int minh); void setMaximumWidth(int maxw); void setMaximumHeight(int maxh); QColor backgroundColor() const; QColor shadowColor() const; QPoint shadowOffset() const; protected: void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; void showEvent(QShowEvent *) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; void closeEvent(QCloseEvent *) Q_DECL_OVERRIDE; void enterEvent(QEvent *)Q_DECL_OVERRIDE; void leaveEvent(QEvent *)Q_DECL_OVERRIDE; void changeEvent(QEvent *event) Q_DECL_OVERRIDE; public Q_SLOTS: void showMinimized(); void showMaximized(); void showFullScreen(); void showNormal(); void moveWindow(Qt::MouseButton botton); void toggleMaximizedWindow(); void setBackgroundColor(QColor backgroundColor); void setShadowColor(QColor shadowColor); void setShadowOffset(QPoint shadowOffset); protected: explicit DX11Widget(DX11WidgetPrivate &dd, QWidget *parent = 0); virtual void drawShadowPixmap(); Q_SIGNALS: void optionClicked(); void backgroundColorChanged(QColor backgroundColor); void shadowColorChanged(QColor shadowColor); void shadowOffsetChanged(QPoint shadowOffset); private: D_PRIVATE_SLOT(void _q_onTitleBarMousePressed(Qt::MouseButtons) const) D_DECLARE_PRIVATE(DX11Widget) }; class FilterMouseMove : public QObject { Q_OBJECT public: explicit FilterMouseMove(QObject *object = nullptr); ~FilterMouseMove(); bool eventFilter(QObject *obj, QEvent *event); //private: QWidget *m_rootWidget = nullptr; }; DWIDGET_END_NAMESPACE #endif // DABSTRACTWIDGET_H dtkwidget-2.0.7.2/src/widgets/dx11window.h000066400000000000000000000012711325435343100202650ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ dtkwidget-2.0.7.2/src/widgets/icons.qrc000066400000000000000000000007631325435343100177360ustar00rootroot00000000000000 images/arrow_right_white.png images/arrow_right_press.png images/arrow_right_normal.png images/arrow_right_hover.png images/arrow_left_white.png images/arrow_left_press.png images/arrow_left_normal.png images/arrow_left_hover.png images/deepin-logo.svg dtkwidget-2.0.7.2/src/widgets/images/000077500000000000000000000000001325435343100173535ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/images/arrow_left_hover.png000066400000000000000000000004431325435343100234310ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?1BCHlH̙3߹sǟdf(^@hi@fY,L3M(Ѐe۷R 6SAΆ1LȆ,\<#4w.RG0qr>`\k"IENDB`dtkwidget-2.0.7.2/src/widgets/images/arrow_left_normal.png000066400000000000000000000005011325435343100235710ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?1BCHyxx˱0aaajjjLj.؅D`asssQhj@RRYiii#ӧ͛g/02W)40]A[nXjD k^ %KA Al$%e4C 1bGR ]2TNIENDB`dtkwidget-2.0.7.2/src/widgets/images/arrow_left_press.png000066400000000000000000000004431325435343100234420ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?1BCHlH̙3߹sǟdf(^@hi@fY,L3M(Ѐe۷R 6SAΆ1LȆ,\<#4w.RG0qr>`\k"IENDB`dtkwidget-2.0.7.2/src/widgets/images/arrow_left_white.png000066400000000000000000000004251325435343100234260ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?%.022ʂhrLh^n]˗/}*} D3N@u͚5}44ݻvyk|Ak *))ebbd}` e<'SqqqPI^ B Yj6ybr^00y\=h:IENDB`dtkwidget-2.0.7.2/src/widgets/images/arrow_right_hover.png000066400000000000000000000004721325435343100236160ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?2 ADž1RA, h`ƍ. E wYAx̙  )4XC1 5k֜b3 ``,T}V 700L0T0A!: ՌR4c5`… ŒP[ۗt̅ bs# H;AaOIENDB`dtkwidget-2.0.7.2/src/widgets/images/arrow_right_normal.png000066400000000000000000000005261325435343100237630ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?2 ADž1xxxRA, h %%hx>###HQ.Լ DI g#(voݺbժUqb k$%%6>}zn޼yxt`~U th/4bP D@f111Uь5~XH%5O` L@A|SYGHIENDB`dtkwidget-2.0.7.2/src/widgets/images/arrow_right_press.png000066400000000000000000000004721325435343100236270ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?2 ADž1RA, h`ƍ. E wYAx̙  )4XC1 5k֜b3 ``,T}V 700L0T0A!: ՌR4c5`… ŒP[ۗt̅ bs# H;AaOIENDB`dtkwidget-2.0.7.2/src/widgets/images/arrow_right_white.png000066400000000000000000000004361325435343100236130ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?%&022ʂhcB`|ѣGUM hX>[D0f#I! f͚>!py?|{n?6y&Qȷd}&&JJJoI D_qqq߿? $qj*b40 L^sqlOrT$IENDB`dtkwidget-2.0.7.2/src/widgets/images/deepin-logo.svg000066400000000000000000000124551325435343100223050ustar00rootroot00000000000000 logo Created with Sketch. dtkwidget-2.0.7.2/src/widgets/private/000077500000000000000000000000001325435343100175605ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/private/daboutdialog_p.h000066400000000000000000000031101325435343100227010ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DABOUTDIALOG_P_H #define DABOUTDIALOG_P_H #include "daboutdialog.h" #include "ddialog_p.h" DWIDGET_BEGIN_NAMESPACE class DAboutDialogPrivate : public DDialogPrivate { public: DAboutDialogPrivate(DAboutDialog *qq); void init(); void initWebsiteInfo(); void updateWebsiteLabel(); void updateAcknowledgementLabel(); void _q_onLinkActivated(const QString &link); QPixmap loadPixmap(const QString &file); static const QString websiteLinkTemplate; QPixmap windowIcon; QLabel *logoLabel; QLabel *productNameLabel; QLabel *versionLabel; QLabel *descriptionLabel; QLabel *licenseLabel; QLabel *companyLogoLabel; QLabel *websiteLabel; QLabel *acknowledgementLabel; QString websiteName; QString websiteLink; QString acknowledgementLink; Q_DECLARE_PUBLIC(DAboutDialog) }; DWIDGET_END_NAMESPACE #endif // DABOUTDIALOG_P_H dtkwidget-2.0.7.2/src/widgets/private/dabstractdialogprivate_p.h000066400000000000000000000031271325435343100247750ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DABSTRACTDIALOG_P_H #define DABSTRACTDIALOG_P_H #include "dabstractdialog.h" #include class QLabel; class QBoxLayout; DWIDGET_BEGIN_NAMESPACE class DPlatformWindowHandle; class DBlurEffectWidget; class DAbstractDialogPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { protected: DAbstractDialogPrivate(DAbstractDialog *qq); QRect getParentGeometry() const; private: void init(); bool mouseMoved = false; /// 记录是否收到过鼠标移动事件. bool mousePressed = false; QPoint dragPosition; QColor backgroundColor; QColor borderColor; DAbstractDialog::DisplayPosition displayPosition = DAbstractDialog::Center; QLabel* windowTitle = Q_NULLPTR; DPlatformWindowHandle *handle = Q_NULLPTR; DBlurEffectWidget *bgBlurWidget = Q_NULLPTR; Q_DECLARE_PUBLIC(DAbstractDialog) }; DWIDGET_END_NAMESPACE #endif // DABSTRACTDIALOG_P_H dtkwidget-2.0.7.2/src/widgets/private/dapplication_p.h000066400000000000000000000040211325435343100227140ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DAPPLICATION_P_H #define DAPPLICATION_P_H #include #include "dapplication.h" #include "dpathbuf.h" #include class QLocalServer; class QTranslator; DCORE_USE_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DAboutDialog; class DApplicationPrivate : public DObjectPrivate { D_DECLARE_PUBLIC(DApplication) public: explicit DApplicationPrivate(DApplication *q); ~DApplicationPrivate(); QString theme() const; void setTheme(const QString &theme); bool setSingleInstanceBySemaphore(const QString &key); #ifdef Q_OS_UNIX bool setSingleInstanceByDbus(const QString &key); #endif bool loadDtkTranslator(QList localeFallback); bool loadTranslator(QList translateDirs, const QString &name, QList localeFallback); static bool isUserManualExists(); public: // int m_pidLockFD = 0; QLocalServer *m_localServer = nullptr; #ifdef Q_OS_UNIX QStringList m_monitoredStartupApps; #endif QString productName; QIcon productIcon; QString appLicense; QString appDescription; QString homePage; QString acknowledgementPage; bool visibleMenuShortcutText = false; bool visibleMenuCheckboxWidget = false; bool visibleMenuIcon = false; DAboutDialog *aboutDialog = Q_NULLPTR; }; DWIDGET_END_NAMESPACE #endif // DAPPLICATION_P_H dtkwidget-2.0.7.2/src/widgets/private/darrowrectangle_p.h000066400000000000000000000047701325435343100234430ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DARROWRECTANGLE_P_H #define DARROWRECTANGLE_P_H #include "darrowrectangle.h" #include #include #include "util/dwindowmanagerhelper.h" DWIDGET_BEGIN_NAMESPACE class DArrowRectanglePrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DArrowRectangle) public: explicit DArrowRectanglePrivate(DArrowRectangle::ArrowDirection direction, DArrowRectangle *q); void init(DArrowRectangle::FloatMode floatMode); virtual void show(int x, int y); void setContent(QWidget *content); void resizeWithContent(); void paintEvent(QPaintEvent *e); void resizeEvent(QResizeEvent *e); QPainterPath getLeftCornerPath(); QPainterPath getRightCornerPath(); QPainterPath getTopCornerPath(); QPainterPath getBottomCornerPath(); const QRect currentScreenRect(const int x, const int y); void verticalMove(int x, int y); void horizontalMove(int x, int y); void updateClipPath(); bool radiusEnabled(); public: int m_radius = 3; int m_arrowHeight = 8; int m_arrowWidth = 12; int m_margin = 5; int m_arrowX = 0; int m_arrowY = 0; qreal m_shadowBlurRadius = 20; qreal m_shadowDistance = 0; qreal m_shadowXOffset = 0; qreal m_shadowYOffset = 5; int m_shadowWidth = 5; //Abandoned int m_borderWidth = 1; QColor m_borderColor = QColor(0, 0, 0, 255 * 0.1); QColor m_backgroundColor = QColor(255, 255, 255, 255); DArrowRectangle::ArrowDirection m_arrowDirection; QPoint m_lastPos = QPoint(0, 0); DArrowRectangle::FloatMode floatMode = DArrowRectangle::FloatWindow; QPointer m_content; DPlatformWindowHandle *m_handle = NULL; DBlurEffectWidget *m_blurBackground = NULL; DWindowManagerHelper *m_wmHelper; }; DWIDGET_END_NAMESPACE #endif // DARROWRECTANGLE_P_H dtkwidget-2.0.7.2/src/widgets/private/dblureffectwidget_p.h000066400000000000000000000036001325435343100237400ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBLUREFFECTWIDGET_P_H #define DBLUREFFECTWIDGET_P_H #include #include "dblureffectwidget.h" DWIDGET_BEGIN_NAMESPACE class DBlurEffectWidgetPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DBlurEffectWidgetPrivate(DBlurEffectWidget *qq); int radius = 10; DBlurEffectWidget::BlurMode mode = DBlurEffectWidget::GaussianBlur; QImage sourceImage; DBlurEffectWidget::BlendMode blendMode = DBlurEffectWidget::InWindowBlend; int blurRectXRadius = 0; int blurRectYRadius = 0; QColor maskColor = Qt::transparent; DBlurEffectWidget::MaskColorType maskColorType = DBlurEffectWidget::CustomColor; QPainterPath maskPath; bool isBehindWindowBlendMode() const; void addToBlurEffectWidgetHash(); void removeFromBlurEffectWidgetHash(); bool updateWindowBlurArea(); void setMaskColor(const QColor &color); static QMultiHash blurEffectWidgetHash; static QHash windowOfBlurEffectHash; static bool updateWindowBlurArea(QWidget *topLevelWidget); private: D_DECLARE_PUBLIC(DBlurEffectWidget) }; DWIDGET_END_NAMESPACE #endif // DBLUREFFECTWIDGET_P_H dtkwidget-2.0.7.2/src/widgets/private/dboxwidget_p.h000066400000000000000000000020671325435343100224150ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBOXWIDGET_P_H #define DBOXWIDGET_P_H #include "dboxwidget.h" #include class QBoxLayout; DWIDGET_BEGIN_NAMESPACE class DBoxWidgetPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DBoxWidgetPrivate(DBoxWidget *qq); QBoxLayout *layout; void init(); Q_DECLARE_PUBLIC(DBoxWidget) }; DWIDGET_END_NAMESPACE #endif // DBOXWIDGET_P_H dtkwidget-2.0.7.2/src/widgets/private/dcircleprogress_p.h000066400000000000000000000025461325435343100234510ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCIRCLEPROGRESS_P_H #define DCIRCLEPROGRESS_P_H #include "dcircleprogress.h" #include #include DWIDGET_BEGIN_NAMESPACE class DCircleProgressPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { Q_DECLARE_PUBLIC(DCircleProgress) public: DCircleProgressPrivate(DCircleProgress *q); private: void paint(QPainter *painter); private: int m_lineWidth = 3; int m_currentValue = 40; int m_minmumValue = 0; int m_maximumValue = 100; QLabel m_topLabel; QLabel m_bottomLabel; QColor m_chunkColor = Qt::cyan; QColor m_backgroundColor = Qt::darkCyan; }; DWIDGET_END_NAMESPACE #endif // DCIRCLEPROGRESS_P_H dtkwidget-2.0.7.2/src/widgets/private/dcombobox_p.h000066400000000000000000000043101325435343100222220ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DCOMBOBOX_P_H #define DCOMBOBOX_P_H #include "dcombobox.h" #include DWIDGET_BEGIN_NAMESPACE class DComboBoxItem; class DComboBoxPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { protected: DComboBoxPrivate(DComboBox *parent); void setMaskLabel(DComboBoxItem *label); private: void init(); void initInsideFrame(); void restylePopupEnds(); void _q_slotCurrentIndexChange(int index); DComboBoxItem *maskLabel = NULL; //mask label QModelIndex hoverIndex; QString normalTickImg = ""; QString hoverTickImg = ""; QString insensitiveTickImg = ""; bool alert = false; QPointer checkedItem; QPointer hoveredItem; const int MAX_VISIBLE_ITEMS = 16; const int OUTSIDE_BORDER_WIDTH = 1; D_DECLARE_PUBLIC(DComboBox) }; class DComboBoxItem : public QLabel { Q_OBJECT Q_PROPERTY(bool checked READ checked WRITE setChecked NOTIFY checkedChanged) Q_PROPERTY(bool hovered READ hovered WRITE setHovered NOTIFY hoveredChanged) public: explicit DComboBoxItem(QWidget *parent = 0); bool checked() const; Q_SLOT void setChecked(bool value); bool hovered() const; Q_SLOT void setHovered(bool value); virtual QVariantMap data() const; virtual void setData(const QVariantMap &map); Q_SIGNALS: void checkedChanged(bool checked); void hoveredChanged(bool hovered); private: bool m_checked = false; bool m_hovered = false; }; DWIDGET_END_NAMESPACE #endif // DCOMBOBOX_P_H dtkwidget-2.0.7.2/src/widgets/private/ddialog_p.h000066400000000000000000000047331325435343100216620ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DDIALOG_P_H #define DDIALOG_P_H #include #include #include "ddialog.h" #include "dabstractdialogprivate_p.h" QT_BEGIN_NAMESPACE class QHBoxLayout; QT_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DImageButton; class DVBoxWidget; class DHBoxWidget; class DialogButton : public QPushButton { Q_OBJECT Q_PROPERTY(int buttonType READ buttonType WRITE setButtonType NOTIFY buttonTypeChanged) public: explicit DialogButton(const QString &text, QWidget *parent = 0); int buttonType() const; public Q_SLOTS: void setButtonType(int buttonType); Q_SIGNALS: void buttonTypeChanged(int buttonType); private: int m_buttonType; }; class DDialogPrivate : public DAbstractDialogPrivate { protected: DDialogPrivate(DDialog *qq); QBoxLayout *getContentLayout(); private: bool onButtonClickedClose = true; QIcon icon; QString title; QString message; Qt::TextFormat textFormat; QLabel* iconLabel; QLabel* messageLabel; QLabel* titleLabel; DImageButton* closeButton = Q_NULLPTR; QHBoxLayout *iconLayout; QVBoxLayout *contentLayout; QHBoxLayout *buttonLayout; QHBoxLayout *topLayout; const QScreen *targetScreen = nullptr; QList buttonList; QList contentList; QPointer defaultButton; int clickedButtonIndex; QStyle *fixedStyle; void init(); const QScreen *getScreen() const; QString trimTag(QString origin) const; QMap scanTags(const QString origin) const; QString elideString(QString str, const QFontMetrics &fm, int width) const; void updateSize(); void _q_onButtonClicked(); void _q_defaultButtonTriggered(); Q_DECLARE_PUBLIC(DDialog) }; DWIDGET_END_NAMESPACE #endif // DDIALOG_P_H dtkwidget-2.0.7.2/src/widgets/private/dfilechooseredit_p.h000066400000000000000000000024671325435343100235750ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DFILECHOOSEREDIT_P_H #define DFILECHOOSEREDIT_P_H #include "dlineedit_p.h" #include "dfilechooseredit.h" #include "dimagebutton.h" DWIDGET_BEGIN_NAMESPACE class DFileChooserEditPrivate : DLineEditPrivate { Q_DECLARE_PUBLIC(DFileChooserEdit) public: DFileChooserEditPrivate(DFileChooserEdit *q); void init(); public: void _q_showFileChooserDialog(); DFileChooserEdit::DialogDisplayPosition dialogDisplayPosition = DFileChooserEdit::FoloowParentWindow; QFileDialog::FileMode fileMode = QFileDialog::ExistingFile; QStringList nameFilters; }; DWIDGET_END_NAMESPACE #endif // DFILECHOOSEREDIT_P_H dtkwidget-2.0.7.2/src/widgets/private/dflowlayout_p.h000066400000000000000000000024121325435343100226200ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DFLOWLAYOUT_P_H #define DFLOWLAYOUT_P_H #include "dflowlayout.h" #include class QLayoutItem; DWIDGET_BEGIN_NAMESPACE class DFlowLayoutPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DFlowLayoutPrivate(DFlowLayout *qq); QSize doLayout(const QRect &rect, bool testOnly) const; QList itemList; int horizontalSpacing = 0; int verticalSpacing = 0; mutable QSize sizeHint; DFlowLayout::Flow flow = DFlowLayout::Flow::LeftToRight; D_DECLARE_PUBLIC(DFlowLayout) }; DWIDGET_END_NAMESPACE #endif // DFLOWLAYOUT_P_H dtkwidget-2.0.7.2/src/widgets/private/dimagebutton_p.h000066400000000000000000000027131325435343100227350ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: kirigaya * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DIMAGEBUTTON_P_H #define DIMAGEBUTTON_P_H #include "dimagebutton.h" #include DWIDGET_BEGIN_NAMESPACE class DImageButtonPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: explicit DImageButtonPrivate(DImageButton *qq); ~DImageButtonPrivate(); void updateIcon(); void setState(DImageButton::State state); QPixmap loadPixmap(const QString &path); DImageButton::State m_state = DImageButton::Normal; bool m_isChecked = false; bool m_isCheckable = false; QString m_normalPic; QString m_hoverPic; QString m_pressPic; QString m_checkedPic; QString m_disabledPic; D_DECLARE_PUBLIC(DImageButton) }; DWIDGET_END_NAMESPACE #endif // DIMAGEBUTTON_P_H dtkwidget-2.0.7.2/src/widgets/private/dinputdialog_p.h000066400000000000000000000025541325435343100227410ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DINPUTDIALOG_P_H #define DINPUTDIALOG_P_H #include "dinputdialog.h" #include "ddialog_p.h" DWIDGET_BEGIN_NAMESPACE class DLabel; class DLineEdit; class DSpinBox; class DDoubleSpinBox; class DComboBox; class DInputDialogPrivate : public DDialogPrivate { DInputDialogPrivate(DInputDialog *qq); QAbstractButton *cancelButton = nullptr; QAbstractButton *okButton = nullptr; DLineEdit *lineEdit = nullptr; DSpinBox* spinBox = nullptr; DDoubleSpinBox *doubleSpinBox = nullptr; DComboBox *comboBox = nullptr; DInputDialog::InputMode inputMode; void init(); D_DECLARE_PUBLIC(DInputDialog) }; DWIDGET_END_NAMESPACE #endif // DINPUTDIALOG_P_H dtkwidget-2.0.7.2/src/widgets/private/dipv4lineedit_p.h000066400000000000000000000024241325435343100230160ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DIPV4LINEEDIT_P_H #define DIPV4LINEEDIT_P_H #include "dlineedit_p.h" #include "dipv4lineedit.h" DWIDGET_BEGIN_NAMESPACE class DIpv4LineEditPrivate : public DLineEditPrivate { DIpv4LineEditPrivate(DIpv4LineEdit *parent); void init(); QLabel *getLabel(); QLineEdit *getEdit(); void setFocus(bool focus); void _q_updateLineEditText(); void _q_setIpLineEditText(const QString &text); QList editList; QWidget *editMainWidget; bool focus = false; D_DECLARE_PUBLIC(DIpv4LineEdit) }; DWIDGET_END_NAMESPACE #endif // DIPV4LINEEDIT_P_H dtkwidget-2.0.7.2/src/widgets/private/dlineedit_p.h000066400000000000000000000026071325435343100222160ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLINEEDIT_P_H #define DLINEEDIT_P_H #include "dlineedit.h" #include "dimagebutton.h" #include #include DWIDGET_BEGIN_NAMESPACE class DArrowRectangle; class DLineEditPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { Q_DECLARE_PUBLIC(DLineEdit) public: DLineEditPrivate(DLineEdit *q); void init(); public Q_SLOTS: void _q_resizeInsideFrame(const QSize &size); void _q_resizeInputableRegion(); public: bool m_isAlert = false; QFrame *m_insideFrame; DImageButton *m_rightIcon; DImageButton *clearButton; QHBoxLayout *m_centralHLayout; DArrowRectangle *tooltip = Q_NULLPTR; }; DWIDGET_END_NAMESPACE #endif // DLINEEDIT_P_H dtkwidget-2.0.7.2/src/widgets/private/dlistview_p.h000066400000000000000000000025121325435343100222620ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLISTVIEW_P_H #define DLISTVIEW_P_H #include "dlistview.h" #include DWIDGET_BEGIN_NAMESPACE class DBoxWidget; class DListViewPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DListViewPrivate(DListView *qq); ~DListViewPrivate(); void init(); void onOrientationChanged(); DBoxWidget *headerLayout = nullptr; DBoxWidget *footerLayout = nullptr; QList headerList; QList footerList; #if(QT_VERSION < 0x050500) int left = 0, top = 0, right = 0, bottom = 0; // viewport margin #endif D_DECLARE_PUBLIC(DListView) }; DWIDGET_END_NAMESPACE #endif // DLISTVIEW_P_H dtkwidget-2.0.7.2/src/widgets/private/dlistwidget_p.h000066400000000000000000000026561325435343100226040ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLISTWIDGET_P_H #define DLISTWIDGET_P_H #include "dscrollarea_p.h" #include "dlistwidget.h" #include "dboxwidget.h" class QVBoxLayout; DWIDGET_BEGIN_NAMESPACE class DListWidgetPrivate : public DScrollAreaPrivate { protected: DListWidgetPrivate(DListWidget *qq); ~DListWidgetPrivate(); private: void init(); int itemWidth; int itemHeight; QList widgetList; QList checkedList; DListWidget::CheckMode checkMode; DBoxWidget *mainWidget; int visibleCount; QMap mapVisible; bool checkable; bool toggleable; bool enableHorizontalScroll; bool enableVerticalScroll; D_DECLARE_PUBLIC(DListWidget) }; DWIDGET_END_NAMESPACE #endif // DLISTWIDGET_P_H dtkwidget-2.0.7.2/src/widgets/private/dloadingindicator_p.h000066400000000000000000000024551325435343100237340ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DLOADINGINDICATOR_P #define DLOADINGINDICATOR_P #include #include "dloadingindicator.h" DWIDGET_BEGIN_NAMESPACE class DLoadingIndicatorPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DLoadingIndicatorPrivate(DLoadingIndicator *qq); void init(); void setLoadingItem(QGraphicsItem *item); QVariantAnimation rotateAni; bool loading; QWidget *widgetSource = NULL; bool smooth = false; DLoadingIndicator::RotationDirection direction = DLoadingIndicator::Clockwise; D_DECLARE_PUBLIC(DLoadingIndicator) }; DWIDGET_END_NAMESPACE #endif // DLOADINGINDICATOR_P dtkwidget-2.0.7.2/src/widgets/private/dmainwindow_p.h000066400000000000000000000024401325435343100225700ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DMAINWINDOW_P_H #define DMAINWINDOW_P_H #include #include "dtkwidget_global.h" #include "dmainwindow.h" class QShortcut; DWIDGET_BEGIN_NAMESPACE class DPlatformWindowHandle; class DTitlebar; class DMainWindowPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DMainWindowPrivate(DMainWindow *qq); void init(); DPlatformWindowHandle *handle = Q_NULLPTR; DTitlebar *titlebar = Q_NULLPTR; QShortcut *help = Q_NULLPTR; private: D_DECLARE_PUBLIC(DMainWindow) }; DWIDGET_END_NAMESPACE #endif // DMAINWINDOW_P_H dtkwidget-2.0.7.2/src/widgets/private/dmpriscontrol_p.h000066400000000000000000000033561325435343100231560ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DMPRISCONTROL_P_H #define DMPRISCONTROL_P_H #include #include "dmpriscontrol.h" #include "dimagebutton.h" #include "private/mpris/dmprismonitor.h" #include "private/mpris/dbusmpris.h" DWIDGET_BEGIN_NAMESPACE class DMPRISControlPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DMPRISControl) public: explicit DMPRISControlPrivate(DMPRISControl *q); void init(); public Q_SLOTS: void _q_onPrevClicked(); void _q_onPlayClicked(); void _q_onPauseClicked(); void _q_onNextClicked(); void _q_onMetaDataChanged(); void _q_onPlaybackStatusChanged(); void _q_loadMPRISPath(const QString &path); void _q_removeMPRISPath(const QString &path); public: DMPRISMonitor *m_mprisMonitor; DBusMPRIS *m_mprisInter; QLabel *m_title; QLabel *m_picture; DImageButton *m_prevBtn; DImageButton *m_playBtn; DImageButton *m_pauseBtn; DImageButton *m_nextBtn; QString m_lastPath; QStringList m_mprisPaths; }; DWIDGET_END_NAMESPACE #endif // DMPRISCONTROL_P_H dtkwidget-2.0.7.2/src/widgets/private/doption_p.h000066400000000000000000000032461325435343100217310ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DOPTION_P_H #define DOPTION_P_H #include "doption.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE class DOptionPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DOption) public: DOptionPrivate(DOption *q); void init(); void setIcon(const QString& iconName); void setIcon(const QPixmap& icon); const QString name() const; const QString value() const; bool checked() const; void setChecked(bool checked); const QString checkedIcon() const; void setCheckedIcon(const QString &icon); void sizeChanged(QResizeEvent *e); public Q_SLOTS: void _q_itemStateChanged(QListWidgetItem* item); public: bool m_checked = false; QString m_optionValue; QString m_checkedIconName; QLabel *m_checkedIconLabel; QLabel *m_optionIcon; QLabel *m_optionName; QHBoxLayout *m_layout; }; DWIDGET_END_NAMESPACE #endif // DOPTION_P_H dtkwidget-2.0.7.2/src/widgets/private/doptionlist_p.h000066400000000000000000000026611325435343100226250ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DOPTIONLIST_P_H #define DOPTIONLIST_P_H #include "doptionlist.h" #include "doption.h" #include #include #include DWIDGET_BEGIN_NAMESPACE class DOptionListPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DOptionList) public: DOptionListPrivate(DOptionList *q); void init(); void addOption(DOption *option); void insertOption(int pos, DOption *option); void setCurrentSelected(int pos); void setCurrentSelected(const QString &value); public Q_SLOTS: void _q_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous); protected: QMap m_optionList; }; DWIDGET_END_NAMESPACE #endif // DOPTIONLIST_P_H dtkwidget-2.0.7.2/src/widgets/private/dpageindicator_p.h000066400000000000000000000025361325435343100232330ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DPAGEINDICATOR_P_H #define DPAGEINDICATOR_P_H #include "dpageindicator.h" #include DWIDGET_BEGIN_NAMESPACE class DPageIndicatorPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DPageIndicator) public: DPageIndicatorPrivate(DPageIndicator *q); void setPageCount(const int count); void nextPage(); void previousPage(); void setCurrentPage(const int index); public: int pointRadius = 5; int secondaryPointRadius = 3; int pointDistance = 12; int pageCount; int currentPage; QColor pointColor; QColor secondaryPointColor; }; DWIDGET_END_NAMESPACE #endif // DPAGEINDICATOR_P_H dtkwidget-2.0.7.2/src/widgets/private/dpasswordedit_p.h000066400000000000000000000020711325435343100231240ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DPASSWORDEDIT_P_H #define DPASSWORDEDIT_P_H #include "dlineedit_p.h" #include "dpasswordedit.h" DWIDGET_BEGIN_NAMESPACE class DPasswordEditPrivate : DLineEditPrivate { public: DPasswordEditPrivate(DPasswordEdit *q); void init(); void _q_toggleEchoMode(); protected: Q_DECLARE_PUBLIC(DPasswordEdit) }; DWIDGET_END_NAMESPACE #endif // DPASSWORDEDIT_P_H dtkwidget-2.0.7.2/src/widgets/private/dpicturesequenceview_p.h000066400000000000000000000027201325435343100245140ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DPICTURESEQUENCEVIEW_P_H #define DPICTURESEQUENCEVIEW_P_H #include "dpicturesequenceview.h" #include #include #include #include DWIDGET_BEGIN_NAMESPACE class DPictureSequenceViewPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DPictureSequenceView) public: DPictureSequenceViewPrivate(DPictureSequenceView *q); ~DPictureSequenceViewPrivate(); void init(); void play(); QPixmap loadPixmap(const QString &path); public: void _q_refreshPicture(); public: int lastItemPos = 0; bool singleShot = false; QGraphicsScene *scene; QTimer *refreshTimer; QList pictureItemList; }; DWIDGET_END_NAMESPACE #endif // DPICTURESEQUENCEVIEW_P_H dtkwidget-2.0.7.2/src/widgets/private/dpushbutton_p.h000066400000000000000000000022331325435343100226270ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DPUSHBUTTON_P_H #define DPUSHBUTTON_P_H #include "dpushbutton.h" #include DWIDGET_BEGIN_NAMESPACE class DPushButtonPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: DPushButtonPrivate(DPushButton *qq); QIcon normalIcon; QIcon hoverIcon; QIcon pressIcon; QString normalIconPath; QString hoverIconPath; QString pressIconPath; D_DECLARE_PUBLIC(DPushButton) }; DWIDGET_END_NAMESPACE #endif // DPUSHBUTTON_P_H dtkwidget-2.0.7.2/src/widgets/private/dscrollarea_p.h000066400000000000000000000024021325435343100225410ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSCROLLAREA_P_H #define DSCROLLAREA_P_H #include "dtkwidget_global.h" #include "dscrollarea.h" #include class QPropertyAnimation; DWIDGET_BEGIN_NAMESPACE class DScrollAreaPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { protected: DScrollAreaPrivate(DScrollArea *qq); ~DScrollAreaPrivate(); private: void init(); bool autoHideScrollBar; DScrollBar *vBar; DScrollBar *hBar; QPropertyAnimation *scrollBarAnimation; QTimer *timer; D_DECLARE_PUBLIC(DScrollArea) }; DWIDGET_END_NAMESPACE #endif // DSCROLLAREA_P_H dtkwidget-2.0.7.2/src/widgets/private/dscrollbar_p.h000066400000000000000000000025461325435343100224060ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSCROLLBAR_P_H #define DSCROLLBAR_P_H #include "dscrollbar.h" #include QT_BEGIN_NAMESPACE class QGraphicsOpacityEffect; QT_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DScrollBarPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DScrollBarPrivate(DScrollBar *qq); void init(); void setOpacity(qreal opacity); void _q_hidden(); void _q_updateOpacity(); bool canPaint = true; bool autoHide = true; qreal opacity = 1; QTimer *timer = Q_NULLPTR; QTimer *opacityTimer = Q_NULLPTR; QGraphicsOpacityEffect *effect = Q_NULLPTR; D_DECLARE_PUBLIC(DScrollBar) }; DWIDGET_END_NAMESPACE #endif // DSCROLLBAR_P_H dtkwidget-2.0.7.2/src/widgets/private/dspinbox_p.h000066400000000000000000000027521325435343100221040ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSPINBOX_P_H #define DSPINBOX_P_H #include "dspinbox.h" #include class QFrame; class QLabel; DWIDGET_BEGIN_NAMESPACE class DImageButton; class DSpinBoxPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DSpinBoxPrivate(DSpinBox *parent); void init(); void _q_resizeInsideFrame(const QSize &size); QFrame *insideFrame; bool alert = false; int defaultValue = 0; D_DECLARE_PUBLIC(DSpinBox) }; class DDoubleSpinBoxPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DDoubleSpinBoxPrivate(DDoubleSpinBox *parent); void init(); void _q_resizeInsideFrame(const QSize &size); QFrame *insideFrame; bool alert = false; double defaultValue = 0; D_DECLARE_PUBLIC(DDoubleSpinBox) }; DWIDGET_END_NAMESPACE #endif // DSPINBOX_P_H dtkwidget-2.0.7.2/src/widgets/private/dstackwidget_p.h000066400000000000000000000032301325435343100227230ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSTACKWIDGET_P_H #define DSTACKWIDGET_P_H #include "dstackwidget.h" #include class QStackedLayout; DWIDGET_BEGIN_NAMESPACE class DAbstractStackWidgetTransitionPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DAbstractStackWidgetTransitionPrivate(DAbstractStackWidgetTransition *qq); ~DAbstractStackWidgetTransitionPrivate(); QVariantAnimation *animation; DAbstractStackWidgetTransition::TransitionInfo info; void init(); D_DECLARE_PUBLIC(DAbstractStackWidgetTransition) }; class DStackWidgetPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DStackWidgetPrivate(DStackWidget *qq); ~DStackWidgetPrivate(); int currentIndex; QWidget *currentWidget; QList widgetList; QList trashWidgetList; DAbstractStackWidgetTransition* transition; void init(); void setCurrentIndex(int index); D_DECLARE_PUBLIC(DStackWidget) }; DWIDGET_END_NAMESPACE #endif // DSTACKWIDGET_P dtkwidget-2.0.7.2/src/widgets/private/dswitchbutton_p.h000066400000000000000000000027051325435343100231550ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * Author: kirigaya * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DSWITCHBUTTON_P_H #define DSWITCHBUTTON_P_H #include "dswitchbutton.h" #include DWIDGET_BEGIN_NAMESPACE class DSwitchButtonPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: explicit DSwitchButtonPrivate(DSwitchButton *qq); ~DSwitchButtonPrivate(); void init(); QPixmap loadPixmap(const QString &path, bool &ok); public: bool m_checked; QPixmap m_enabledImage; QPixmap m_disabledImage; QVariantAnimation *m_innerAnimation; double m_animationStartValue; double m_animationEndValue; QString m_disabledImageSource; QString m_enabledImageSource; public: D_DECLARE_PUBLIC(DSwitchButton) }; DWIDGET_END_NAMESPACE #endif // DSWITCHBUTTON_P_H dtkwidget-2.0.7.2/src/widgets/private/dtextedit_p.h000066400000000000000000000020341325435343100222450ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTEXTEDIT_P_H #define DTEXTEDIT_P_H #include "dtextedit.h" #include DWIDGET_BEGIN_NAMESPACE class DTextEditPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { DTextEditPrivate(DTextEdit *qq); void init(); QFrame *insideFrame; D_DECLARE_PUBLIC(DTextEdit) }; DWIDGET_END_NAMESPACE #endif // DTEXTEDIT_P_H dtkwidget-2.0.7.2/src/widgets/private/dthemehelper.cpp000066400000000000000000000016541325435343100227400ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dthemehelper.h" DThemeHelper::DThemeHelper(QObject *parent) : QObject(parent) { } QString DThemeHelper::themeToQss(QString theme) { return theme; } QString DThemeHelper::trimThemeContents(QString qss) { return qss; } dtkwidget-2.0.7.2/src/widgets/private/dthemehelper.h000066400000000000000000000017301325435343100224000ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTHEMEHELPER_H #define DTHEMEHELPER_H #include class DThemeHelper : public QObject { Q_OBJECT public: explicit DThemeHelper(QObject *parent = 0); QString themeToQss(QString theme); QString trimThemeContents(QString qss); }; #endif // DTHEMEHELPER_H dtkwidget-2.0.7.2/src/widgets/private/dtickeffect_p.h000066400000000000000000000024261325435343100225270ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DTICKEFFECTPRIVATE_H #define DTICKEFFECTPRIVATE_H #include "dtickeffect.h" #include #include #include DWIDGET_BEGIN_NAMESPACE class DTickEffectPrivate : public DTK_CORE_NAMESPACE::DObjectPrivate { public: explicit DTickEffectPrivate(DTickEffect *qq); ~DTickEffectPrivate(); void init(); void initDirection(); public: DTickEffect::Direction direction; int duration; QVariantAnimation *runAnimation; QWidget *content; D_DECLARE_PUBLIC(DTickEffect) }; DWIDGET_END_NAMESPACE #endif // DTICKEFFECTPRIVATE_H dtkwidget-2.0.7.2/src/widgets/private/dwidget_p.h000066400000000000000000000045651325435343100217110ustar00rootroot00000000000000/* * Copyright (C) 2015 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DWDIGET_P_H #define DWDIGET_P_H #include #include "dwidget.h" #include "../../platforms/x11/xutil.h" class QVBoxLayout; class QGraphicsDropShadowEffect; class DX11Widget; DWIDGET_BEGIN_NAMESPACE class DX11WidgetPrivate: public DTK_CORE_NAMESPACE::DObjectPrivate { D_DECLARE_PUBLIC(DX11Widget) public: explicit DX11WidgetPrivate(DX11Widget *q); void init(); QSize externSize(const QSize &size) const; QMargins externMargins() const; int externWidth() const; void updateContentsMargins(); void _q_onTitleBarMousePressed(Qt::MouseButtons buttons) const; bool leftPressed; bool resizable; int m_ShadowWidth; int m_NormalShadowWidth; int m_Radius; int m_Border; int m_ResizeHandleWidth; bool m_MousePressed; QPoint m_LastMousePos; Qt::WindowFlags dwindowFlags; DWidget::DecorationFlags decorationFlags; QColor m_backgroundColor; QColor shadowColor; QPoint shadowOffset; QPixmap m_Background; QPixmap shadowPixmap; QWidget *windowWidget = nullptr; QVBoxLayout *rootLayout = nullptr; DTitlebar *titlebar = nullptr; QWidget *contentWidget = nullptr; XUtils::CornerEdge resizingCornerEdge = XUtils::CornerEdge::kInvalid; }; class DWidgetPrivate: public DX11WidgetPrivate { D_DECLARE_PUBLIC(DWidget) public: explicit DWidgetPrivate(DWidget *q); bool leftPressed; bool resizable; }; DWIDGET_END_NAMESPACE #endif // DWDIGET_P_H dtkwidget-2.0.7.2/src/widgets/private/mpris/000077500000000000000000000000001325435343100207125ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/private/mpris/dbusinterface.cpp000066400000000000000000000025761325435343100242460ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dbusinterface.h" /* * Implementation of interface class DBusInterface */ DBusInterface::DBusInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) { QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); } DBusInterface::~DBusInterface() { QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage))); } dtkwidget-2.0.7.2/src/widgets/private/mpris/dbusinterface.h000066400000000000000000000153021325435343100237020ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBUSINTERFACE_H #define DBUSINTERFACE_H #include #include #include #include #include #include #include #include /* * Proxy class for interface org.freedesktop.DBus */ class DBusInterface: public QDBusAbstractInterface { Q_OBJECT Q_SLOT void __propertyChanged__(const QDBusMessage& msg) { QList arguments = msg.arguments(); if (3 != arguments.count()) return; QString interfaceName = msg.arguments().at(0).toString(); if (interfaceName != "org.freedesktop.DBus") return; QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); Q_FOREACH(const QString &prop, changedProps.keys()) { const QMetaObject* self = metaObject(); for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) { QMetaProperty p = self->property(i); QGenericArgument value(QMetaType::typeName(p.type()), const_cast(changedProps[prop].constData())); if (p.name() == prop) { Q_EMIT p.notifySignal().invoke(this, value); } } } } public: static inline const char *staticInterfaceName() { return "org.freedesktop.DBus"; } public: DBusInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~DBusInterface(); public Q_SLOTS: // METHODS inline QDBusPendingReply<> AddMatch(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("AddMatch"), argumentList); } inline QDBusPendingReply GetAdtAuditSessionData(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("GetAdtAuditSessionData"), argumentList); } inline QDBusPendingReply GetConnectionSELinuxSecurityContext(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("GetConnectionSELinuxSecurityContext"), argumentList); } inline QDBusPendingReply GetConnectionUnixProcessID(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("GetConnectionUnixProcessID"), argumentList); } inline QDBusPendingReply GetConnectionUnixUser(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("GetConnectionUnixUser"), argumentList); } inline QDBusPendingReply GetId() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("GetId"), argumentList); } inline QDBusPendingReply GetNameOwner(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("GetNameOwner"), argumentList); } inline QDBusPendingReply Hello() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Hello"), argumentList); } inline QDBusPendingReply ListActivatableNames() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("ListActivatableNames"), argumentList); } inline QDBusPendingReply ListNames() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("ListNames"), argumentList); } inline QDBusPendingReply ListQueuedOwners(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("ListQueuedOwners"), argumentList); } inline QDBusPendingReply NameHasOwner(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("NameHasOwner"), argumentList); } inline QDBusPendingReply ReleaseName(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("ReleaseName"), argumentList); } inline QDBusPendingReply<> ReloadConfig() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("ReloadConfig"), argumentList); } inline QDBusPendingReply<> RemoveMatch(const QString &in0) { QList argumentList; argumentList << QVariant::fromValue(in0); return asyncCallWithArgumentList(QStringLiteral("RemoveMatch"), argumentList); } inline QDBusPendingReply RequestName(const QString &in0, uint in1) { QList argumentList; argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); return asyncCallWithArgumentList(QStringLiteral("RequestName"), argumentList); } inline QDBusPendingReply StartServiceByName(const QString &in0, uint in1) { QList argumentList; argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); return asyncCallWithArgumentList(QStringLiteral("StartServiceByName"), argumentList); } Q_SIGNALS: // SIGNALS void NameAcquired(const QString &in0); void NameLost(const QString &in0); void NameOwnerChanged(const QString &in0, const QString &in1, const QString &in2); // begin property changed signals }; namespace org { namespace freedesktop { typedef ::DBusInterface DBus; } } #endif dtkwidget-2.0.7.2/src/widgets/private/mpris/dbusmpris.cpp000066400000000000000000000025461325435343100234350ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dbusmpris.h" /* * Implementation of interface class DBusMPRIS */ DBusMPRIS::DBusMPRIS(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) { QDBusConnection::sessionBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); } DBusMPRIS::~DBusMPRIS() { QDBusConnection::sessionBus().disconnect(service(), path(), "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertyChanged(QDBusMessage))); } dtkwidget-2.0.7.2/src/widgets/private/mpris/dbusmpris.h000066400000000000000000000174441325435343100231050ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DBUSMPRIS_H #define DBUSMPRIS_H #include #include #include #include #include #include #include #include /* * Proxy class for interface org.mpris.MediaPlayer2.Player */ class DBusMPRIS: public QDBusAbstractInterface { Q_OBJECT Q_SLOT void __propertyChanged__(const QDBusMessage& msg) { QList arguments = msg.arguments(); if (3 != arguments.count()) return; QString interfaceName = msg.arguments().at(0).toString(); if (interfaceName != "org.mpris.MediaPlayer2.Player") return; QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); Q_FOREACH(const QString &prop, changedProps.keys()) { const QMetaObject* self = metaObject(); for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) { QMetaProperty p = self->property(i); QGenericArgument value(QMetaType::typeName(p.type()), const_cast(changedProps[prop].constData())); if (p.name() == prop) { Q_EMIT p.notifySignal().invoke(this, value); } } } } public: static inline const char *staticInterfaceName() { return "org.mpris.MediaPlayer2.Player"; } public: DBusMPRIS(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~DBusMPRIS(); Q_PROPERTY(bool CanControl READ canControl NOTIFY CanControlChanged) inline bool canControl() const { return qvariant_cast< bool >(property("CanControl")); } Q_PROPERTY(bool CanGoNext READ canGoNext NOTIFY CanGoNextChanged) inline bool canGoNext() const { return qvariant_cast< bool >(property("CanGoNext")); } Q_PROPERTY(bool CanGoPrevious READ canGoPrevious NOTIFY CanGoPreviousChanged) inline bool canGoPrevious() const { return qvariant_cast< bool >(property("CanGoPrevious")); } Q_PROPERTY(bool CanPause READ canPause NOTIFY CanPauseChanged) inline bool canPause() const { return qvariant_cast< bool >(property("CanPause")); } Q_PROPERTY(bool CanPlay READ canPlay NOTIFY CanPlayChanged) inline bool canPlay() const { return qvariant_cast< bool >(property("CanPlay")); } Q_PROPERTY(bool CanSeek READ canSeek NOTIFY CanSeekChanged) inline bool canSeek() const { return qvariant_cast< bool >(property("CanSeek")); } Q_PROPERTY(QString LoopStatus READ loopStatus WRITE setLoopStatus NOTIFY LoopStatusChanged) inline QString loopStatus() const { return qvariant_cast< QString >(property("LoopStatus")); } inline void setLoopStatus(const QString &value) { setProperty("LoopStatus", QVariant::fromValue(value)); } Q_PROPERTY(double MaximumRate READ maximumRate NOTIFY MaximumRateChanged) inline double maximumRate() const { return qvariant_cast< double >(property("MaximumRate")); } Q_PROPERTY(QVariantMap Metadata READ metadata NOTIFY MetadataChanged) inline QVariantMap metadata() const { return qvariant_cast< QVariantMap >(property("Metadata")); } Q_PROPERTY(double MinimumRate READ minimumRate NOTIFY MinimumRateChanged) inline double minimumRate() const { return qvariant_cast< double >(property("MinimumRate")); } Q_PROPERTY(QString PlaybackStatus READ playbackStatus NOTIFY PlaybackStatusChanged) inline QString playbackStatus() const { return qvariant_cast< QString >(property("PlaybackStatus")); } Q_PROPERTY(qlonglong Position READ position NOTIFY PositionChanged) inline qlonglong position() const { return qvariant_cast< qlonglong >(property("Position")); } Q_PROPERTY(double Rate READ rate WRITE setRate NOTIFY RateChanged) inline double rate() const { return qvariant_cast< double >(property("Rate")); } inline void setRate(double value) { setProperty("Rate", QVariant::fromValue(value)); } Q_PROPERTY(bool Shuffle READ shuffle WRITE setShuffle NOTIFY ShuffleChanged) inline bool shuffle() const { return qvariant_cast< bool >(property("Shuffle")); } inline void setShuffle(bool value) { setProperty("Shuffle", QVariant::fromValue(value)); } Q_PROPERTY(double Volume READ volume WRITE setVolume NOTIFY VolumeChanged) inline double volume() const { return qvariant_cast< double >(property("Volume")); } inline void setVolume(double value) { setProperty("Volume", QVariant::fromValue(value)); } public Q_SLOTS: // METHODS inline QDBusPendingReply<> Next() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Next"), argumentList); } inline QDBusPendingReply<> OpenUri(const QString &Uri) { QList argumentList; argumentList << QVariant::fromValue(Uri); return asyncCallWithArgumentList(QStringLiteral("OpenUri"), argumentList); } inline QDBusPendingReply<> Pause() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Pause"), argumentList); } inline QDBusPendingReply<> Play() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Play"), argumentList); } inline QDBusPendingReply<> PlayPause() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("PlayPause"), argumentList); } inline QDBusPendingReply<> Previous() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Previous"), argumentList); } inline QDBusPendingReply<> Seek(qlonglong Offset) { QList argumentList; argumentList << QVariant::fromValue(Offset); return asyncCallWithArgumentList(QStringLiteral("Seek"), argumentList); } inline QDBusPendingReply<> SetPosition(const QDBusObjectPath &TrackId, qlonglong Position) { QList argumentList; argumentList << QVariant::fromValue(TrackId) << QVariant::fromValue(Position); return asyncCallWithArgumentList(QStringLiteral("SetPosition"), argumentList); } inline QDBusPendingReply<> Stop() { QList argumentList; return asyncCallWithArgumentList(QStringLiteral("Stop"), argumentList); } Q_SIGNALS: // SIGNALS void Seeked(qlonglong Position); // begin property changed signals void CanControlChanged(bool value); void CanGoNextChanged(bool value); void CanGoPreviousChanged(bool value); void CanPauseChanged(bool value); void CanPlayChanged(bool value); void CanSeekChanged(bool value); void LoopStatusChanged(const QString & value); void MaximumRateChanged(double value); void MetadataChanged(const QVariantMap & value); void MinimumRateChanged(double value); void PlaybackStatusChanged(const QString & value); void PositionChanged(qlonglong value); void RateChanged(double value); void ShuffleChanged(bool value); void VolumeChanged(double value); }; namespace org { namespace mpris { namespace MediaPlayer2 { typedef ::DBusMPRIS Player; } } } #endif dtkwidget-2.0.7.2/src/widgets/private/mpris/dmprismonitor.cpp000066400000000000000000000027401325435343100243270ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "dmprismonitor.h" #include DMPRISMonitor::DMPRISMonitor(QObject *parent) : QObject(parent), m_dbusInter(new DBusInterface("org.freedesktop.DBus", "/org/freedesktop/DBus", QDBusConnection::sessionBus(), this)) { } void DMPRISMonitor::init() { connect(m_dbusInter, &DBusInterface::NameOwnerChanged, this, &DMPRISMonitor::onNameOwnerChanged); for (const auto &name : m_dbusInter->ListNames().value()) onNameOwnerChanged(name, QString(), name); } void DMPRISMonitor::onNameOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner) { Q_UNUSED(oldOwner); if (!name.startsWith("org.mpris.MediaPlayer2.")) return; if (newOwner.isEmpty()) Q_EMIT mprisLost(name); else Q_EMIT mprisAcquired(name); } dtkwidget-2.0.7.2/src/widgets/private/mpris/dmprismonitor.h000066400000000000000000000023061325435343100237720ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef DMPRISMONITOR_H #define DMPRISMONITOR_H #include "dbusinterface.h" #include class DMPRISMonitor : public QObject { Q_OBJECT public: explicit DMPRISMonitor(QObject *parent = 0); void init(); Q_SIGNALS: void mprisAcquired(const QString &path) const; void mprisLost(const QString &path) const; private Q_SLOTS: void onNameOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); private: DBusInterface *m_dbusInter; }; #endif // DMPRISMONITOR_H dtkwidget-2.0.7.2/src/widgets/private/mpris/org.freedesktop.DBus.xml000066400000000000000000000046371325435343100254030ustar00rootroot00000000000000 dtkwidget-2.0.7.2/src/widgets/private/mpris/org.mpris.MediaPlayer2.xml000066400000000000000000000063411325435343100256350ustar00rootroot00000000000000 dtkwidget-2.0.7.2/src/widgets/private/private.pri000066400000000000000000000024721325435343100217530ustar00rootroot00000000000000linux{ HEADERS += \ $$PWD/mpris/dmprismonitor.h \ $$PWD/mpris/dbusinterface.h \ $$PWD/dmpriscontrol_p.h \ $$PWD/mpris/dbusmpris.h SOURCES += \ $$PWD/mpris/dmprismonitor.cpp \ $$PWD/mpris/dbusinterface.cpp \ $$PWD/mpris/dbusmpris.cpp } HEADERS += \ $$PWD/dthemehelper.h \ $$PWD/dcircleprogress_p.h \ $$PWD/dlineedit_p.h \ $$PWD/dfilechooseredit_p.h \ $$PWD/dstackwidget_p.h \ $$PWD/dscrollarea_p.h \ $$PWD/dlistwidget_p.h \ $$PWD/dboxwidget_p.h \ $$PWD/dpasswordedit_p.h \ $$PWD/dabstractdialogprivate_p.h \ $$PWD/ddialog_p.h \ $$PWD/dloadingindicator_p.h \ $$PWD/dinputdialog_p.h \ $$PWD/dipv4lineedit_p.h \ $$PWD/dspinbox_p.h \ $$PWD/dcombobox_p.h \ $$PWD/doptionlist_p.h \ $$PWD/doption_p.h \ $$PWD/dpicturesequenceview_p.h \ $$PWD/dflowlayout_p.h \ $$PWD/dlistview_p.h \ $$PWD/dtextedit_p.h \ $$PWD/dapplication_p.h \ $$PWD/dwidget_p.h \ $$PWD/dscrollbar_p.h \ $$PWD/dmainwindow_p.h \ $$PWD/dblureffectwidget_p.h \ $$PWD/dpageindicator_p.h \ $$PWD/daboutdialog_p.h \ $$PWD/darrowrectangle_p.h \ $$PWD/dpushbutton_p.h \ $$PWD/dtickeffect_p.h \ $$PWD/dswitchbutton_p.h \ $$PWD/dimagebutton_p.h SOURCES += \ $$PWD/dthemehelper.cpp dtkwidget-2.0.7.2/src/widgets/private/settings/000077500000000000000000000000001325435343100214205ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/private/settings/buttongroup.cpp000066400000000000000000000064531325435343100245240ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "buttongroup.h" #include #include #include class ButtonGroupPrivate { public: ButtonGroupPrivate(ButtonGroup *parent) : q_ptr(parent){} QHBoxLayout *layout = nullptr; QButtonGroup *group = nullptr; ButtonGroup *q_ptr; Q_DECLARE_PUBLIC(ButtonGroup) }; ButtonGroup::ButtonGroup(QWidget *parent) : QFrame(parent), d_ptr(new ButtonGroupPrivate(this)) { Q_D(ButtonGroup); setObjectName("ButtonGroup"); d->group = new QButtonGroup; d->layout = new QHBoxLayout(this); d->layout->setSpacing(0); d->layout->setMargin(0); connect(d->group,static_cast(&QButtonGroup::buttonReleased), this, [=](int){ Q_EMIT buttonChecked(d->group->checkedId()); }); } ButtonGroup::~ButtonGroup() { } void ButtonGroup::setCheckedButton(int id) { Q_D(ButtonGroup); if (d->group->button(id)) { d->group->button(id)->setChecked(true); } } void ButtonGroup::setButtons(const QStringList &texts) { Q_D(ButtonGroup); int i = 0; for (auto text: texts) { auto bt = new QPushButton(text); bt->setFixedWidth(36); bt->setFixedHeight(22); bt->setCheckable(true); if (texts.length() <= 1) bt->setObjectName("ButtonGroupSingle"); // bt->setStyleSheet("QPushButton{border: 1px solid red; border-radius: 4.0px}"); else { if (i == 0) bt->setObjectName("ButtonGroupBegin"); // bt->setStyleSheet("QPushButton{" // "border: 1px solid red;" // "border-top-left-radius: 4.0px;" // "border-bottom-left-radius: 4.0px;" // "}"); else if (i == texts.length() -1) { bt->setObjectName("ButtonGroupEnd"); // bt->setStyleSheet("QPushButton{" // "border: 1px solid red;" // "border-top-right-radius: 4.0px;" // "border-bottom-right-radius: 4.0px;" // "}"); } else { bt->setObjectName("ButtonGroupMiddle"); // bt->setStyleSheet("QPushButton{" // "border-top: 1px solid red;" // "border-bottom: 1px solid red;" // "}"); } } d->group->addButton(bt, i); d->layout->addWidget(bt); i++; } d->layout->addStretch(); } dtkwidget-2.0.7.2/src/widgets/private/settings/buttongroup.h000066400000000000000000000022201325435343100241550ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include class ButtonGroupPrivate; class ButtonGroup : public QFrame { Q_OBJECT public: explicit ButtonGroup(QWidget *parent = 0); ~ButtonGroup(); Q_SIGNALS: void buttonChecked(int id); public Q_SLOTS: void setCheckedButton(int id); void setButtons(const QStringList &texts); private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), ButtonGroup) }; dtkwidget-2.0.7.2/src/widgets/private/settings/combobox.cpp000066400000000000000000000015761325435343100237450ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "combobox.h" ComboBox::ComboBox(QWidget *parent) : QComboBox(parent) { } void ComboBox::wheelEvent(QWheelEvent *e) { if (hasFocus()) { QComboBox::wheelEvent(e); } } dtkwidget-2.0.7.2/src/widgets/private/settings/combobox.h000066400000000000000000000015741325435343100234100ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include class ComboBox : public QComboBox { Q_OBJECT public: explicit ComboBox(QWidget *parent = 0); void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE; }; dtkwidget-2.0.7.2/src/widgets/private/settings/content.cpp000066400000000000000000000141371325435343100236040ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "content.h" #include #include #include #include #include #include #include #include #include #include "dsettingswidgetfactory.h" #include "contenttitle.h" DWIDGET_BEGIN_NAMESPACE class ContentPrivate { public: ContentPrivate(Content *parent) : q_ptr(parent) { widgetFactory = new DSettingsWidgetFactory; } QScrollArea *contentArea; QWidget *contentFrame; QVBoxLayout *contentLayout; QMap titles; DSettingsWidgetFactory *widgetFactory; Content *q_ptr; Q_DECLARE_PUBLIC(Content) }; Content::Content(QWidget *parent) : QFrame(parent), d_ptr(new ContentPrivate(this)) { Q_D(Content); setObjectName("RightFrame"); setContentsMargins(0, 0, 0, 0); auto layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); d->contentArea = new QScrollArea; d->contentArea->setContentsMargins(0, 0, 0, 0); d->contentArea->setWidgetResizable(true); d->contentArea->setStyleSheet("QScrollArea{border: none; background-color: transparent; }"); // d->contentArea->setStyleSheet("QFrame{border: 1px solid red;}"); d->contentFrame = new QWidget(this); d->contentFrame->setObjectName("SettingsContent"); d->contentFrame->setStyleSheet("#SettingsContent{border: none; background-color: transparent; }"); d->contentLayout = new QVBoxLayout(d->contentFrame); d->contentLayout->setContentsMargins(20, 0, 0, 0); d->contentLayout->setSpacing(0); layout->addWidget(d->contentArea); d->contentArea->setWidget(d->contentFrame); connect(d->contentArea->verticalScrollBar(), &QScrollBar::valueChanged, this, [ = ](int value) { Q_D(Content); auto offset = std::numeric_limits::max(); auto closedTitle = d->titles.first(); for (auto title : d->titles) { // not the hide if ((title->y() + title->height()) < value) { continue; } auto titleOffset = title->y() + title->height() - value; if (titleOffset < offset) { offset = titleOffset; closedTitle = title; } } if (closedTitle) { // qDebug() << "send scrollToGroup" << closedTitle->property("key"); Q_EMIT scrollToGroup(closedTitle->property("key").toString()); } }); } Content::~Content() { } DSettingsWidgetFactory *Content::widgetFactory() const { Q_D(const Content); return d->widgetFactory; } void Content::onScrollToGroup(const QString &key) { Q_D(Content); auto title = d->titles.value(key); this->blockSignals(true); d->contentArea->verticalScrollBar()->setValue(title->y()); this->blockSignals(false); // qDebug() << "onScrollToGroup" << key; } void Content::updateSettings(QPointer settings) { Q_D(Content); for (auto groupKey : settings->groupKeys()) { auto group = settings->group(groupKey); if (group->isHidden()) { continue; } auto trName = QObject::tr(group->name().toStdString().c_str()); auto title = new ContentTitle; title->setTitle(trName); title->setProperty("key", groupKey); // d->contentLayout->addSpacing(10); d->contentLayout->addWidget(title); d->contentLayout->addSpacing(8); d->titles.insert(groupKey, title); for (auto subgroup : settings->group(groupKey)->childGroups()) { if (subgroup->isHidden()) { continue; } if (!subgroup->name().isEmpty()) { auto title = new QLabel; title->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); title->setObjectName("ContentSubTitleText"); title->setFixedHeight(20); auto trName = QObject::tr(subgroup->name().toStdString().c_str()); title->setText(trName); title->setProperty("key", subgroup->key()); title->setStyleSheet("#ContentSubTitleText{font-weight: 520; " // "border: 1px solid red; " "font-size: 12px;" "}"); d->contentLayout->addWidget(title); d->contentLayout->addSpacing(10); d->titles.insert(subgroup->key(), title); } for (auto option : subgroup->childOptions()) { if (option->isHidden()) { continue; } auto widget = d->widgetFactory->createWidget(option); if (widget) { d->contentLayout->addWidget(widget); widget->setParent(d->contentFrame); } } d->contentLayout->addSpacing(4); } } auto resetBt = new QPushButton(QObject::tr("Restore Defaults")); resetBt->setObjectName("SettingsContentReset"); resetBt->setFixedSize(310, 36); d->contentLayout->addSpacing(40); d->contentLayout->addWidget(resetBt, 0, Qt::AlignCenter); d->contentLayout->addSpacing(40); d->contentLayout->addStretch(); connect(resetBt, &QPushButton::released, this, [ = ]() { settings->reset(); }); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/private/settings/content.h000066400000000000000000000026641325435343100232530ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include #include "dtkwidget_global.h" DCORE_BEGIN_NAMESPACE class DSettings; DCORE_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE class DSettingsWidgetFactory; class ContentPrivate; class LIBDTKWIDGETSHARED_EXPORT Content : public QFrame { Q_OBJECT public: explicit Content(QWidget *parent = 0); ~Content(); DSettingsWidgetFactory* widgetFactory() const; Q_SIGNALS: void scrollToGroup(const QString &key); public Q_SLOTS: void onScrollToGroup(const QString &key); void updateSettings(QPointer settings); private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), Content) }; DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/private/settings/contenttitle.cpp000066400000000000000000000036731325435343100246510ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "contenttitle.h" #include #include class ContentTitlePrivate { public: ContentTitlePrivate(ContentTitle *parent) : q_ptr(parent) {} QLabel *titleLabel = nullptr; ContentTitle *q_ptr; Q_DECLARE_PUBLIC(ContentTitle) }; ContentTitle::ContentTitle(QWidget *parent) : QWidget(parent), d_ptr(new ContentTitlePrivate(this)) { Q_D(ContentTitle); setObjectName("ContentTitle"); auto layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(10); d->titleLabel = new QLabel(); d->titleLabel->setObjectName("ContentTitleText"); layout->addWidget(d->titleLabel, 0, Qt::AlignLeft); d->titleLabel->setStyleSheet("#ContentTitleText{font-weight: 550; font-size: 14px;}"); auto lineLabel = new QLabel; lineLabel->setObjectName("ContentTitleLine"); lineLabel->setFixedHeight(1); lineLabel->setStyleSheet("#ContentTitleLine{border: 1px solid rgba(0,0,0,0.1);}"); layout->addWidget(lineLabel); lineLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); setFixedHeight(20); } ContentTitle::~ContentTitle() { } void ContentTitle::setTitle(const QString &title) { Q_D(ContentTitle); d->titleLabel->setText(title); } dtkwidget-2.0.7.2/src/widgets/private/settings/contenttitle.h000066400000000000000000000021171325435343100243060ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include class ContentTitlePrivate; class ContentTitle : public QWidget { Q_OBJECT public: explicit ContentTitle(QWidget *parent = 0); ~ContentTitle(); Q_SIGNALS: public Q_SLOTS: void setTitle(const QString &title); private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), ContentTitle) }; dtkwidget-2.0.7.2/src/widgets/private/settings/navigation.cpp000066400000000000000000000124441325435343100242700ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "navigation.h" #include #include #include #include #include #include #include "navigationdelegate.h" DWIDGET_BEGIN_NAMESPACE class NavigationPrivate { public: NavigationPrivate(Navigation *parent) : q_ptr(parent) {} QListView *navbar = nullptr; QStandardItemModel *navbarModel = nullptr; Navigation *q_ptr; Q_DECLARE_PUBLIC(Navigation) }; Navigation::Navigation(QWidget *parent) : QFrame(parent), d_ptr(new NavigationPrivate(this)) { Q_D(Navigation); setObjectName("Navigation"); // setStyleSheet("#Navigation{border: none; border-right: 1px solid rgba(0,0,0,0.1);}"); setContentsMargins(0, 0, 0, 0); auto layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); d->navbar = new QListView(this); d->navbar->setObjectName("NavigationBar"); // d->navbar->setStyleSheet("#NavigationBar{border: none;}"); // d->navbar->setMinimumWidth(160); // d->navbar->setMaximumWidth(199); d->navbar->setContentsMargins(0, 0, 0, 0); d->navbar->setSelectionMode(QListView::SingleSelection); d->navbar->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); d->navbar->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); d->navbarModel = new QStandardItemModel; d->navbar->setModel(d->navbarModel); d->navbar->setEditTriggers(QAbstractItemView::NoEditTriggers); d->navbar->setItemDelegate(new NavigationDelegate); layout->addWidget(d->navbar); connect(d->navbar, &QListView::clicked, this, [ = ](const QModelIndex & index) { qDebug() << index.data(NavigationDelegate::NavKeyRole); auto key = index.data(NavigationDelegate::NavKeyRole).toString(); if (!key.isEmpty()) { Q_EMIT selectedGroup(index.data(NavigationDelegate::NavKeyRole).toString()); } }); // setMaximumWidth(200); d->navbar->setFixedWidth(190); setFixedWidth(190 + 1); } Navigation::~Navigation() { } void Navigation::onSelectGroup(const QString &key) { Q_D(Navigation); for (int i = 0; i < d->navbarModel->rowCount(); ++i) { auto index = d->navbarModel->index(i, 0); if (index.data(NavigationDelegate::NavKeyRole).toString() == key) { d->navbar->setCurrentIndex(index); return; } } } void Navigation::updateSettings(QPointer settings) { Q_D(Navigation); bool first = true; for (auto groupKey : settings->groupKeys()) { if (!first) { auto item = new QStandardItem; item->setData("", Qt::DisplayRole); item->setData(NavigationDelegate::Split, NavigationDelegate::NavLevelRole); d->navbarModel->appendRow(item); } first = false; auto group = settings->group(groupKey); if (group->isHidden()) { continue; } auto item = new QStandardItem; auto trName = QObject::tr(group->name().toStdString().c_str()); // qDebug() << settings->group(groupKey)->name() << trName; // QFont font(item->data(Qt::FontRole).value()); // QFontMetrics fm(font); // int width = fm.width(trName); // qDebug() << ">>>>>>>>>>> " << font << trName << width; item->setData(trName, Qt::DisplayRole); item->setData(NavigationDelegate::Level1, NavigationDelegate::NavLevelRole); item->setData(groupKey, NavigationDelegate::NavKeyRole); d->navbarModel->appendRow(item); for (auto subgroup : settings->group(groupKey)->childGroups()) { if (subgroup->isHidden()) { continue; } if (subgroup->name().isEmpty()) { continue; } auto item = new QStandardItem; auto trName = QObject::tr(subgroup->name().toStdString().c_str()); // qDebug() << subgroup->name() << trName; // QFont font(item->data(Qt::FontRole).value()); // QFontMetrics fm(font); // int width = fm.width(trName); // qDebug() << "<<<<<<<<<<<< " << font << trName << width; item->setData(trName, Qt::DisplayRole); item->setData(NavigationDelegate::Level2, NavigationDelegate::NavLevelRole); item->setData(subgroup->key(), NavigationDelegate::NavKeyRole); d->navbarModel->appendRow(item); } } d->navbar->setCurrentIndex(d->navbarModel->index(0, 0)); // this->adjustSize(); // d->navbar->setMaximumWidth(200); // this->setFixedWidth(d->navbar->width() + 1); } DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/private/settings/navigation.h000066400000000000000000000025371325435343100237370ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include #include "dtkwidget_global.h" DCORE_BEGIN_NAMESPACE class DSettings; DCORE_END_NAMESPACE DWIDGET_BEGIN_NAMESPACE class NavigationPrivate; class LIBDTKWIDGETSHARED_EXPORT Navigation : public QFrame { Q_OBJECT public: explicit Navigation(QWidget *parent = 0); ~Navigation(); Q_SIGNALS: void selectedGroup(const QString &key); public Q_SLOTS: void onSelectGroup(const QString &key); void updateSettings(QPointer settings); private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), Navigation) }; DWIDGET_END_NAMESPACE dtkwidget-2.0.7.2/src/widgets/private/settings/navigationdelegate.cpp000066400000000000000000000105471325435343100257650ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "navigationdelegate.h" #include #include class NavigationDelegatePrivate { public: NavigationDelegatePrivate(NavigationDelegate *parent) : q_ptr(parent) {} NavigationDelegate *q_ptr; Q_DECLARE_PUBLIC(NavigationDelegate) }; NavigationDelegate::NavigationDelegate(QWidget *parent) : QStyledItemDelegate(parent) , d_ptr(new NavigationDelegatePrivate(this)) { } NavigationDelegate::~NavigationDelegate() { } void NavigationDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { painter->save(); painter->setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing); painter->setBrush(option.palette.foreground()); auto level = static_cast(index.data(NavLevelRole).toInt()); bool isSelected = option.state & QStyle::State_Selected; switch (level) { case Level1: case Level2: { if (isSelected) { auto brush = QColor("#d5edfe"); painter->fillRect(option.rect, brush); auto rect = option.rect; rect.setX(option.rect.x() + option.rect.width() - 3); brush = QColor("#2ca7f8"); painter->fillRect(rect, brush); } } case Split: case Level3: break; } switch (level) { case Level1: { auto pen = isSelected ? QColor("#2ca7f8") : QColor("#00162c"); painter->setPen(pen); auto rect = option.rect.marginsRemoved(QMargins(30, 0, 0, 0)); auto font = painter->font(); font.setPixelSize(16); font.setWeight(QFont::DemiBold); painter->setFont(font); QFontMetrics fm(font); auto text = fm.elidedText(index.data().toString(), Qt::ElideMiddle, 150); painter->drawText(rect, Qt::AlignLeft | Qt::AlignVCenter, text); break; } case Level2: { auto pen = isSelected ? QColor("#2ca7f8") : QColor("#303030"); painter->setPen(pen); auto font = painter->font(); font.setPixelSize(12); painter->setFont(font); QFontMetrics fm(font); auto text = fm.elidedText(index.data().toString(), Qt::ElideMiddle, 135); auto rect = option.rect.marginsRemoved(QMargins(45, 0, 0, 0)); painter->drawText(rect, Qt::AlignLeft | Qt::AlignVCenter, text); break; } case Split: case Level3: break; } painter->restore(); } QSize NavigationDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { auto sh = QStyledItemDelegate::sizeHint(option, index); auto level = static_cast(index.data(NavLevelRole).toInt()); switch (level) { case Split: { sh.setHeight(20); break; } case Level1: case Level2: case Level3: sh.setHeight(30); break; } return sh; } QWidget *NavigationDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { return QStyledItemDelegate::createEditor(parent, option, index); } void NavigationDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QStyledItemDelegate::setEditorData(editor, index); } void NavigationDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QStyledItemDelegate::setModelData(editor, model, index); } void NavigationDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const { QStyledItemDelegate::initStyleOption(option, index); } dtkwidget-2.0.7.2/src/widgets/private/settings/navigationdelegate.h000066400000000000000000000036541325435343100254330ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include class NavigationDelegatePrivate; class NavigationDelegate: public QStyledItemDelegate { Q_OBJECT public: NavigationDelegate(QWidget *parent = 0); ~NavigationDelegate(); enum DataRole { NavLevelRole = Qt::UserRole + 100, NavKeyRole, }; enum NavLevel { Split = 1001, Level1, Level2, Level3 }; virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setEditorData(QWidget *editor, const QModelIndex &index) const; void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), NavigationDelegate) }; dtkwidget-2.0.7.2/src/widgets/private/settings/shortcutedit.cpp000066400000000000000000000163551325435343100246570ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "shortcutedit.h" #include #include #include #include namespace { const int MAX_WIDTH = 238; const int MAX_HEIGHT = 22 + 2 * 2; const double BORDER_RADIUS = 3.0; const QColor ACTIVE_BORDER_COLOR = QColor("#2ca7f8"); const QColor NORMAL_BORDER_COLOR = QColor(0, 0, 0, 255 * 8 / 100); } static bool isModifiersKey(int key) { QList keys; keys << Qt::Key_Shift; keys << Qt::Key_Control; keys << Qt::Key_Alt; keys << Qt::Key_Meta; return keys.contains(key); } class ShortcutEditPrivate { public: ShortcutEditPrivate(ShortcutEdit *parent) : q_ptr(parent) {} QSize stringSize(const QString &str) const; QRectF drawTextRect(const QRect &lastRect, const QString &str, QPainter &painter) const; Qt::KeyboardModifiers keyModifiers = Qt::NoModifier; Qt::Key key = Qt::Key_unknown; QStringList keyStringList; bool canSet = true; QColor borderColor = NORMAL_BORDER_COLOR; ShortcutEdit *q_ptr; Q_DECLARE_PUBLIC(ShortcutEdit) }; ShortcutEdit::ShortcutEdit(QWidget *parent) : QWidget(parent), d_ptr(new ShortcutEditPrivate(this)) { // Q_D(ShortcutEdit); setFixedSize(MAX_WIDTH, MAX_HEIGHT); setFocusPolicy(Qt::ClickFocus); } ShortcutEdit::~ShortcutEdit() { } void ShortcutEdit::setShortCut(Qt::KeyboardModifiers modifier, Qt::Key key) { Q_D(ShortcutEdit); d->keyModifiers = modifier; d->key = key; d->keyStringList.clear(); if (d->keyModifiers != Qt::NoModifier) { d->keyStringList << QKeySequence(d->keyModifiers).toString().split("+", QString::SkipEmptyParts); } if (d->key != Qt::Key_unknown) { d->keyStringList << QKeySequence(d->key).toString(); } } void ShortcutEdit::setShortCut(const QString &sequenceString) { Q_D(ShortcutEdit); // replcae ++ to sep_plus const QString sepString = "sep_str"; const QString plusString = "sep_plus"; QString formatSequenceString = QString(sequenceString).replace("++", plusString); formatSequenceString = formatSequenceString.replace("+", sepString); formatSequenceString = formatSequenceString.replace(plusString, sepString + "+"); d->keyStringList = formatSequenceString.split(sepString); } void ShortcutEdit::paintEvent(QPaintEvent *) { Q_D(const ShortcutEdit); QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing); if (d->keyStringList.isEmpty()) { // Draw tips QRect tR(6, 5, width(), height()); QFont f; f.setPixelSize(11); painter.setFont(f); painter.setPen(QPen(QColor(48, 48, 48, 255 * 4 / 10))); painter.drawText(tR, tr("Please enter a new shortcut")); } else { QRectF lastRect(1, 0, 0, 0); for (QString key : d->keyStringList) { painter.save(); lastRect = d->drawTextRect(lastRect.toRect(), key, painter); painter.restore(); } } auto borderRadius = BORDER_RADIUS; auto penWidthf = 1.0; QPainterPath borderPath; QRectF borderRect = QRectF(rect()); QMarginsF borderMargin(penWidthf / 2, penWidthf / 2, penWidthf / 2, penWidthf / 2); borderRadius -= penWidthf / 2; borderRect = borderRect.marginsRemoved(borderMargin); borderPath.addRoundedRect(borderRect, borderRadius, borderRadius); QPen borderPen(d->borderColor); borderPen.setWidthF(penWidthf); painter.strokePath(borderPath, borderPen); } void ShortcutEdit::focusInEvent(QFocusEvent *e) { Q_UNUSED(e) Q_D(ShortcutEdit); d->borderColor = ACTIVE_BORDER_COLOR; this->update(); } void ShortcutEdit::focusOutEvent(QFocusEvent *e) { Q_UNUSED(e) Q_D(ShortcutEdit); d->borderColor = NORMAL_BORDER_COLOR; this->update(); } void ShortcutEdit::keyPressEvent(QKeyEvent *e) { Q_D(ShortcutEdit); if (e->key() != Qt::Key_Backspace) { if (isModifiersKey(e->key()) || ! d->canSet) { return; } d->canSet = true; if (e->key() == Qt::Key_Delete) { d->keyModifiers = e->modifiers(); d->key = static_cast(e->key()); } else { d->keyModifiers = e->modifiers(); d->key = static_cast(e->key()); } d->keyStringList.clear(); if (d->keyModifiers != Qt::NoModifier) { d->keyStringList << QKeySequence(d->keyModifiers).toString().split("+", QString::SkipEmptyParts); } if (d->key != Qt::Key_unknown) { d->keyStringList << QKeySequence(d->key).toString(); } } else { d->canSet = true; d->key = Qt::Key_unknown; d->keyModifiers = Qt::NoModifier; d->keyStringList.clear(); } notifyShortcutChanged(d->keyModifiers, d->key); this->update(); } void ShortcutEdit::mouseDoubleClickEvent(QMouseEvent *event) { Q_D(ShortcutEdit); if (event->button() == Qt::LeftButton) { d->canSet = true; d->key = Qt::Key_unknown; d->keyModifiers = Qt::NoModifier; notifyShortcutChanged(d->keyModifiers, d->key); } this->update(); } void ShortcutEdit::notifyShortcutChanged(Qt::KeyboardModifiers modifier, Qt::Key key) { QKeySequence modifierSeq(modifier); QKeySequence keySeq(key); QString seqString = modifierSeq.toString() + keySeq.toString(); Q_EMIT shortcutStringChanged(seqString); Q_EMIT shortcutChanged(modifier, key); } QSize ShortcutEditPrivate::stringSize(const QString &str) const { QFont f; f.setPixelSize(10); QFontMetrics fm(f); int w = fm.boundingRect(str).width(); int h = fm.height(); return QSize(w, h); } QRectF ShortcutEditPrivate::drawTextRect(const QRect &lastRect, const QString &str, QPainter &painter) const { const QSize ss = stringSize(str); QRectF r(lastRect.x() + lastRect.width() + 5, 2 + 2, ss.width() + 6 * 2, 18); QPainterPath bp; bp.addRoundedRect(r, BORDER_RADIUS, BORDER_RADIUS); painter.setClipPath(bp); painter.fillRect(r, QColor(105, 170, 255, 255 * 0.15)); // Draw inside border painter.setPen(QPen(QColor(95, 159, 217, 255 * 0.3), 1)); QPainterPathStroker stroker; stroker.setWidth(1.0); stroker.setJoinStyle(Qt::RoundJoin); QPainterPath borderPath = stroker.createStroke(bp); painter.drawPath(borderPath); // Draw text QRectF tR(r.x() + 6, 5, r.width(), r.height()); QFont f; f.setPixelSize(10); painter.setFont(f); painter.setPen(QPen(QColor("#434343"))); painter.drawText(tR, str); return r; } dtkwidget-2.0.7.2/src/widgets/private/settings/shortcutedit.h000066400000000000000000000034341325435343100243160ustar00rootroot00000000000000/* * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include #include class ShortcutEditPrivate; class ShortcutEdit : public QWidget { Q_OBJECT public: explicit ShortcutEdit(QWidget *parent = 0); ~ShortcutEdit(); void setShortCut(Qt::KeyboardModifiers modifier, Qt::Key key); void setShortCut(const QString &sequenceString); Q_SIGNALS: // WARINNG: just connect one of this on one time // these two signal will send at them same time void shortcutChanged(Qt::KeyboardModifiers modifier, Qt::Key key); void shortcutStringChanged(const QString &sequenceString); protected: virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE; virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE; virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE; virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void notifyShortcutChanged(Qt::KeyboardModifiers modifier, Qt::Key key); private: QScopedPointer d_ptr; Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), ShortcutEdit) }; dtkwidget-2.0.7.2/src/widgets/startupnotifications/000077500000000000000000000000001325435343100224025ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/startupnotifications/startupnotificationmonitor.cpp000066400000000000000000000074201325435343100306320ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "startupnotificationmonitor.h" class StartupNotificationMonitorSub : public StartupNotificationMonitor { }; Q_GLOBAL_STATIC(StartupNotificationMonitorSub, StartupNotificationMonitorInstance) static SnDisplay *display; static SnMonitorContext *context; static void monitor_event_func (SnMonitorEvent *event, void *user_data) { SnMonitorContext *context; SnStartupSequence *sequence; context = sn_monitor_event_get_context (event); sequence = sn_monitor_event_get_startup_sequence (event); const char* app_id = sn_startup_sequence_get_id(sequence); StartupNotificationMonitor *monitor = static_cast(user_data); switch (sn_monitor_event_get_type (event)) { case SN_MONITOR_EVENT_INITIATED: qDebug() << "startup notification initiated: " << app_id; Q_EMIT monitor->appStartup(app_id); break; case SN_MONITOR_EVENT_CHANGED: break; case SN_MONITOR_EVENT_COMPLETED: qDebug() << "startup notification completed: " << app_id; Q_EMIT monitor->appStartupCompleted(app_id); break; case SN_MONITOR_EVENT_CANCELED: qDebug() << "startup notification canceled: " << app_id; break; } } /*! * \class StartupNotificationMonitor * \brief The StartupNotificationMonitor class is used to monitor the startup of applications on the system. * * As the stated in https://specifications.freedesktop.org/startup-notification-spec/startup-notification-0.1.txt, \n * StartupNotificationMonitor monitors all the startup events on the system and notifies the user of application \n * startup and startup finish. */ StartupNotificationMonitor::StartupNotificationMonitor() : QObject() { int screen = 0; xcb_screen_t *s = xcb_aux_get_screen (QX11Info::connection(), screen); const uint32_t select_input_val[] = { XCB_EVENT_MASK_PROPERTY_CHANGE }; xcb_change_window_attributes (QX11Info::connection(), s->root, XCB_CW_EVENT_MASK, select_input_val); display = sn_xcb_display_new (QX11Info::connection(), NULL, NULL); context = sn_monitor_context_new (display, screen, monitor_event_func, this, NULL); qApp->installNativeEventFilter(this); } /** * @brief StartupNotificationMonitor::StartupNotificationMonitor::instance * @return an instance of the StartupNotificationMonitor instance. */ StartupNotificationMonitor* StartupNotificationMonitor::StartupNotificationMonitor::instance() { return StartupNotificationMonitorInstance; } StartupNotificationMonitor::~StartupNotificationMonitor() { qApp->removeNativeEventFilter(this); } bool StartupNotificationMonitor::nativeEventFilter(const QByteArray &eventType, void *message, long *) { if(Q_LIKELY(eventType == "xcb_generic_event_t")) { xcb_generic_event_t* event = static_cast(message); sn_xcb_display_process_event (display, event); } return false; } dtkwidget-2.0.7.2/src/widgets/startupnotifications/startupnotificationmonitor.h000066400000000000000000000031271325435343100302770ustar00rootroot00000000000000/* * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef STARTUPNOTIFICATIONMONITOR_H #define STARTUPNOTIFICATIONMONITOR_H #include #include class StartupNotificationMonitor : public QObject, public QAbstractNativeEventFilter { Q_OBJECT public: static StartupNotificationMonitor* instance(); ~StartupNotificationMonitor(); Q_SIGNALS: /** * @brief appStartup is emitted when an application is starting up. * @param id is the startup id associated with the startup. */ void appStartup(QString id); /** * @brief appStartupCompleted is emitted when the start up process of an applciation is finished. * @param id is the startup id associated with the startup. */ void appStartupCompleted(QString id); protected: StartupNotificationMonitor(); bool nativeEventFilter(const QByteArray &eventType, void *message, long *result); }; #endif // STARTUPNOTIFICATIONMONITOR_H dtkwidget-2.0.7.2/src/widgets/startupnotifications/startupnotifications.pri000066400000000000000000000003641325435343100274150ustar00rootroot00000000000000CONFIG += c++11 link_pkgconfig PKGCONFIG += xcb-util libstartup-notification-1.0 INCLUDEPATH += $$PWD DEFINES += SN_API_NOT_YET_FROZEN HEADERS += \ $$PWD/startupnotificationmonitor.h SOURCES += \ $$PWD/startupnotificationmonitor.cpp dtkwidget-2.0.7.2/src/widgets/themes/000077500000000000000000000000001325435343100173735ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/dark/000077500000000000000000000000001325435343100203145ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DAboutDialog.theme000066400000000000000000000007471325435343100257410ustar00rootroot00000000000000QLabel#ProductNameLabel { font-size:18px; color: black; } QLabel#VersionLabel { font-size:12px; color: #666666; } QLabel#WebsiteLabel { font-size:13px; color: #004EE5; } QLabel#AcknowledgementLabel { font-size:13px; color: #004EE5; } QLabel#DescriptionLabel { font-size:11px; font-weight: normal; color:#1A1A1A; border: none; } QLabel#LicenseLabel { font-size:11px; font-weight: normal; color:#1A1A1A; border: none; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DAbstractDialog.theme000066400000000000000000000002601325435343100264200ustar00rootroot00000000000000Dtk--Widget--DAbstractDialog { qproperty-backgroundColor: rgba(0, 0, 0, 0.8); qproperty-borderColor: rgba(0, 0, 0, 0.2); border-width: 1; border-radius: 4px; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DArrowButton.theme000066400000000000000000000031621325435343100260270ustar00rootroot00000000000000Dtk--Widget--ArrowButtonIcon { background-repeat: no-repeat; background-position: center; } QLabel#ArrowButtonIconNormal[arrowButtonDirection="0"] { background-image: url(:/images/dark/images/arrow_up_normal.png); } QLabel#ArrowButtonIconNormal[arrowButtonDirection="1"] { background-image: url(:/images/dark/images/arrow_down_normal.png); } QLabel#ArrowButtonIconNormal[arrowButtonDirection="2"] { background-image: url(:/images/dark/images/arrow_left_normal.png); } QLabel#ArrowButtonIconNormal[arrowButtonDirection="3"] { background-image: url(:/images/dark/images/arrow_right_normal.png); } QLabel#ArrowButtonIconHover[arrowButtonDirection="0"] { background-image: url(:/images/dark/images/arrow_up_hover.png); } QLabel#ArrowButtonIconHover[arrowButtonDirection="1"] { background-image: url(:/images/dark/images/arrow_down_hover.png); } QLabel#ArrowButtonIconHover[arrowButtonDirection="2"] { background-image: url(:/images/dark/images/arrow_left_hover.png); } QLabel#ArrowButtonIconHover[arrowButtonDirection="3"] { background-image: url(:/images/dark/images/arrow_right_hover.png); } QLabel#ArrowButtonIconPress[arrowButtonDirection="0"] { background-image: url(:/images/dark/images/arrow_up_press.png); } QLabel#ArrowButtonIconPress[arrowButtonDirection="1"] { background-image: url(:/images/dark/images/arrow_down_press.png); } QLabel#ArrowButtonIconPress[arrowButtonDirection="2"] { background-image: url(:/images/dark/images/arrow_left_press.png); } QLabel#ArrowButtonIconPress[arrowButtonDirection="3"] { background-image: url(:/images/dark/images/arrow_right_press.png); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DBaseButton.theme000066400000000000000000000013601325435343100256050ustar00rootroot00000000000000Dtk--Widget--DBaseButton { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #272727, stop: 1.0 #191919); border-width: 1px; border-style: solid; border-radius: 3; border-color: rgba(0, 0, 0, 255); } Dtk--Widget--DBaseButton:pressed { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #181818, stop: 1.0 #282828); } Dtk--Widget--DBaseButton:flat { border: none; /* no border for a flat push button */ } QFrame#ButtonInsideFrame { background-color: transparent; border-top-width: 1px; border-style: solid; border-radius: 3; border-top-color: rgba(255, 255, 255, 26); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DBaseExpand.theme000066400000000000000000000000751325435343100255530ustar00rootroot00000000000000Dtk--Widget--ContentLoader { background-color: #1A1B1B } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DBaseLine.theme000066400000000000000000000001531325435343100252200ustar00rootroot00000000000000/*Dtk--Widget--DBaseLine { background-color: #252627 }*/ /*use default background color(transparent)*/ dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DBoxWidget.theme000066400000000000000000000000701325435343100254300ustar00rootroot00000000000000Dtk--Widget--DBoxWidget{ background: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DButtonList.theme000066400000000000000000000015161325435343100256510ustar00rootroot00000000000000Dtk--Widget--DButtonList { background-color: #1A1B1B; border: none; outline: none; } Dtk--Widget--DButtonList::item { border: none; outline: none; } Dtk--Widget--DButtonList QPushButton:hover{ color: white; } Dtk--Widget--DButtonList QFrame#BorderFrame{ background-color: transparent; } Dtk--Widget--DButtonList QPushButton{ background-color: transparent; color: #b4b4b4; border: none; border-radius:3px; text-align: left center; padding-left: 40px; } Dtk--Widget--DButtonList QPushButton:checked{ background-color: #66000000; color: #2ca7f8; } Dtk--Widget--DButtonList QPushButton:checked[state="OnlyOne"]{ background-color: transparent; color:#01BDFF; } Dtk--Widget--DButtonList QPushButton:checked[state="normal"]{ background-color: lightblack; color:#01BDFF; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DCircleProgress.theme000066400000000000000000000003171325435343100264660ustar00rootroot00000000000000Dtk--Widget--DCircleProgress { qproperty-backgroundColor:rgba(255, 255, 255, .2); qproperty-chunkColor:#26aeed; } Dtk--Widget--DCircleProgress #DisplayLabel { color:white; font-size:10px; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DComboBox.theme000066400000000000000000000077771325435343100252710ustar00rootroot00000000000000Dtk--Widget--DComboBox { border: 1px solid; border-color: black; border-radius: 4px; padding: 1px 1px 1px 4px; color: #b4b4b4; font-size: 12px; qproperty-insensitiveTickImg: url(:/images/dark/images/tick_insensitive.png); qproperty-hoverTickImg: url(:/images/dark/images/tick_hover.png); qproperty-normalTickImg: url(:/images/dark/images/tick_hover.png); background-color: rgba(255, 255, 255, 26);/*use as outside border*/ } Dtk--Widget--DComboBox:!editable, DComboBox::drop-down:editable { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #272727, stop: 1.0 #191919); /*combobox-popup: 0;*/ } /* DComboBox gets the "on" state when the popup is open */ Dtk--Widget--DComboBox:!editable:on, DComboBox::drop-down:editable:on { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #181818, stop: 1.0 #282828); } QAbstractItemView#DComboBoxItemView { selection-background-color: rgba(0,0,0,0.4); background: transparent; margin: 0; font-size: 12px; } QComboBoxPrivateContainer { border: 1px solid black; background-color: #191919; } QAbstractItemView#DComboBoxItemView::item { min-height: 24; color: #b4b4b4; } Dtk--Widget--DComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: center right; width: 16px; margin-right: 3; border-top-right-radius: 4px; /* same radius as the DComboBox */ border-bottom-right-radius: 4px; } Dtk--Widget--DComboBox::down-arrow { image: url(:/images/dark/images/arrow_down_normal.png); } Dtk--Widget--DComboBox::down-arrow:hover { image: url(:/images/dark/images/arrow_down_hover.png); } QAbstractItemView Dtk--Widget--DComboBoxItem { color: #b4b4b4; font-size: 12px; margin-left: 24; margin-bottom: 3; } QAbstractItemView Dtk--Widget--DComboBoxItem[hovered="true"] { color: white; } QAbstractItemView Dtk--Widget--DComboBoxItem[checked="true"] { color: #01BDFF; } #DComboBoxTitleMask{ color: #b4b4b4; padding-left: 10px; } QFrame#DComboxInsideFrame { background-color: transparent; /* border-top-width: 1px; border-style: solid; border-radius: 3; border-top-color: rgba(255, 255, 255, 26); */ border: 1px solid; border-radius: 4px; border-top-color: rgba(255,255,255,26); border-left-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(255,255,255,26), stop: 1.0 rgba(255,255,255,5)); border-right-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(255,255,255,26), stop: 1.0 rgba(255,255,255,5)); border-bottom-color: rgba(255, 255, 255, 5); } QFrame#ComboboxPopupTopEnd { border-bottom: 1px solid #222; border-top-left-radius: 4; border-top-right-radius: 4; background: transparent url(:/images/dark/images/combobox_up_arrow.png); background-repeat: no-repeat; background-position: center; } QFrame#ComboboxPopupBottomEnd { border-top: 1px solid #222; border-bottom-left-radius: 4; border-bottom-right-radius: 4; background: transparent url(:/images/dark/images/combobox_down_arrow.png); background-repeat: no-repeat; background-position: center; } Dtk--Widget--DComboBox:editable{ border: 2px solid transparent; border-bottom: 1px solid #15FFFFFF; padding: 0px 0px 1px 0px; min-height: 21px; background-color: rgba(255, 255, 255, 26); } QLineEdit { background: transparent; border-right: 1px solid rgba(255, 255, 255, 50); margin-right: 4px; } Dtk--Widget--DComboBox[editable="true"] QFrame#DComboxInsideFrame {/*outside frame*/ background-color: rgba(0, 0, 0, 50); border: 1px solid black; } Dtk--Widget--DComboBox[alert="true"] QFrame#DComboxInsideFrame{ border-color: #FF8F00; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DDialog.theme000066400000000000000000000042501325435343100247370ustar00rootroot00000000000000Dtk--Widget--DDialog{ qproperty-backgroundColor: white; qproperty-borderColor: rgba(0, 0, 0, 0.2); } QFrame#ButtonFrame{ border:1px solid rgba(0, 0, 0, 0.1); border-radius: 2px; } #CloseButton{ qproperty-normalPic: url(:/images/light/images/window/close_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/close_hover.svg); qproperty-pressPic: url(:/images/light/images/window/close_press.svg); } QPushButton#NormalButton{ background-color: transparent; border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 2px; color: white; text-align: center; } QPushButton#NormalButton:hover{ background-color: transparent; color: rgba(0, 0, 0, 0.5); } QPushButton#NormalButton:pressed{ background-color: transparent; color: #01bdff; } QPushButton#ActionButton{ background-color: transparent; border: 1px solid rgba(0, 0, 0, 0.1); border-right: none; border-left: none; border-bottom: none; font-size: 13px; color: #303030; text-align: center; outline: none; } QPushButton#ActionButton[buttonType="1"] {/*warning*/ color: #ff5a5a; font-weight: 500; } QPushButton#ActionButton[buttonType="2"] {/*recommend*/ color: #0087ff; font-weight: 500; } QPushButton#ActionButton:hover{ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #8ccfff, stop:1 #4bb8ff); color: #ffffff; } QPushButton#ActionButton:pressed{ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #0b8cff, stop:1 #0aa1ff); color: #ffffff; } QPushButton#ConflictButton{ background-color: transparent; border:none; color: white; text-align: center; } QPushButton#ConflictButton:checked{ background-color: #ff9327; } QLabel#VLine{ background-color:rgba(0, 0, 0, 0.1); } QLabel#TitleLabel{ padding-top: 2px; padding-bottom: 2px; color: #000000; } QLabel#MessageLabel{ padding-top: 2px; padding-bottom: 2px; color: #444444; } QLabel#TaskTitleLabel{ padding-top: 2px; padding-bottom: 2px; font-size: 10px; color: #b4b4b4; } QListWidget{ background-color: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DFileChooserEdit.theme000066400000000000000000000003661325435343100265540ustar00rootroot00000000000000Dtk--Widget--DFileChooserEdit { qproperty-normalIcon:url(:/images/dark/images/loadfile_normal.png); qproperty-hoverIcon:url(:/images/dark/images/loadfile_hover.png); qproperty-pressIcon:url(:/images/dark/images/loadfile_press.png); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DHeaderLine.theme000066400000000000000000000001041325435343100255320ustar00rootroot00000000000000QLabel#DHeaderLineTitle { color: #b4b4b4; font-size: 12px; }dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DImageButton.theme000066400000000000000000000001261325435343100257540ustar00rootroot00000000000000Dtk--Widget--DImageButton:disabled { border: none; background: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DIpv4LineEdit.theme000066400000000000000000000004071325435343100260000ustar00rootroot00000000000000#DIpv4LineEdit_Edit{ border: none; background: transparent; color: #fff; } #DIpv4LineEdit_Label{ color: #fff; } Dtk--Widget--DIpv4LineEdit{ color: transparent; selection-background-color: transparent; selection-color: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DLabel.theme000066400000000000000000000000751325435343100245600ustar00rootroot00000000000000Dtk--Widget--DLabel { color: #b4b4b4; font-size: 12px; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DLineEdit.theme000066400000000000000000000016721325435343100252420ustar00rootroot00000000000000Dtk--Widget--DLineEdit { min-height: 22px; color: #fff; border-radius: 3; background-color: rgba(255, 255, 255, 26);/*use as outside border*/ } Dtk--Widget--DLineEdit[alert="true"] QFrame#LineEditInsideFrame{ border-color: #FF8F00; } QFrame#LineEditInsideFrame {/*outside frame*/ background-color: rgba(0, 0, 0, 50); border: 1px solid; border-radius: 3; border-color: black; } Dtk--Widget--DLineEdit #IconButton { border: 0px solid; border-left: 1px solid rgba(0, 0, 0, 50); margin: 1px 0px 2px 0px; } Dtk--Widget--DLineEdit[alert="true"] #IconButton{ border-color: #FF8F00; } Dtk--Widget--DLineEdit #ClearButton { qproperty-normalPic: ":/images/dark/images/input_clear_normal.svg"; qproperty-hoverPic: ":/images/dark/images/input_clear_hover.svg"; qproperty-pressPic: "/images/dark/images/input_clear_press.svg"; margin-right: 4px; } #AlertTooltip QLabel { color: #FF8F00; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DLinkButton.theme000066400000000000000000000003001325435343100256210ustar00rootroot00000000000000Dtk--Widget--DLinkButton { background-color:transparent; border:none; color:#b4b4b4; } Dtk--Widget--DLinkButton:hover { color:#01BDFF; } Dtk--Widget--DLinkButton:pressed { } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DListView.theme000066400000000000000000000002111325435343100252770ustar00rootroot00000000000000QAbstractScrollArea{ border: none; background: transparent; } QAbstractScrollArea::corner{ background-color: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DLoadingIndicator.theme000066400000000000000000000001761325435343100267550ustar00rootroot00000000000000Dtk--Widget--DLoadingIndicator { background: transparent; qproperty-backgroundColor: transparent; border: none; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DOption.theme000066400000000000000000000007641325435343100250160ustar00rootroot00000000000000 Dtk--Widget--DOption { margin:0 10px; padding:0 10px; qproperty-checkedIcon:url(:/images/dark/images/tick_transparent.png); } Dtk--Widget--DOption[checked="true"] { background-color: lightblack; border-radius:3px; qproperty-checkedIcon:url(:/images/dark/images/tick_hover.png); } Dtk--Widget--DOption #OptionName { color: #b4b4b4; } Dtk--Widget--DOption #OptionName:hover { color: white; } Dtk--Widget--DOption[checked="true"] #OptionName { color: #2ca7f8; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DOptionList.theme000066400000000000000000000015241325435343100256450ustar00rootroot00000000000000Dtk--Widget--DOptionList { background-color: #1A1B1B; border: none; outline: none; } Dtk--Widget--DOptionList::item { border: none; outline: none; } /* Dtk--Widget--DOptionList QPushButton:hover{ color: white; } Dtk--Widget--DButtonList QFrame#BorderFrame{ background-color: transparent; } Dtk--Widget--DButtonList QPushButton{ background-color: transparent; color: #b4b4b4; border: none; border-radius:3px; text-align: left center; padding-left: 40px; } Dtk--Widget--DButtonList QPushButton:checked{ background-color: #66000000; color: #2ca7f8; } Dtk--Widget--DButtonList QPushButton:checked[state="OnlyOne"]{ background-color: transparent; color:#01BDFF; } Dtk--Widget--DButtonList QPushButton:checked[state="normal"]{ background-color: lightblack; color:#01BDFF; } */ dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DPasswordEdit.theme000066400000000000000000000023321325435343100261470ustar00rootroot00000000000000Dtk--Widget--DPasswordEdit { } Dtk--Widget--DPasswordEdit[isEchoMode="false"] #IconButton { border-radius: 2px; border-top-left-radius: 0px; border-bottom-left-radius: 0px; qproperty-normalPic:url(:/images/dark/images/show_password_normal.svg); qproperty-hoverPic:url(:/images/dark/images/show_password_hover.svg); qproperty-pressPic:url(:/images/dark/images/show_password_press.svg); } Dtk--Widget--DPasswordEdit[isEchoMode="true"] Dtk--Widget--DImageButton { border-radius: 2px; border-top-left-radius: 0px; border-bottom-left-radius: 0px; qproperty-normalPic:url(:/images/dark/images/hide_password_normal.svg); qproperty-hoverPic:url(:/images/dark/images/hide_password_hover.svg); qproperty-pressPic:url(:/images/dark/images/hide_password_press.svg); } Dtk--Widget--DPasswordEdit #IconButton[state="hover"] { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #8ccfff, stop: 1.0 #4bb8ff); } Dtk--Widget--DPasswordEdit #IconButton[state="press"] { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #0b8cff, stop: 1.0 #0aa1ff); } Dtk--Widget--DPasswordEdit[alert="true"] #IconButton{ border-color: #FF8F00; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DScrollArea.theme000066400000000000000000000002231325435343100255630ustar00rootroot00000000000000Dtk--Widget--DScrollArea{ border: none; background: transparent; } Dtk--Widget--DScrollArea::corner{ background-color: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DScrollBar.theme000066400000000000000000000014721325435343100254260ustar00rootroot00000000000000Dtk--Widget--DScrollBar::add-line,Dtk--Widget--DScrollBar::sub-line,Dtk--Widget--DScrollBar::add-page,Dtk--Widget--DScrollBar::sub-page{ background-color: transparent; } Dtk--Widget--DScrollBar{ max-width: 10; margin-right: 1px; background-color: transparent; } Dtk--Widget--DScrollBar::handle{ background-color: rgba(255,255,255,0.2); border-radius: 2px; margin: 4px 2px 4px 2px; } Dtk--Widget--DScrollBar::handle:vertical{ min-height: 20px; width: 8px; } Dtk--Widget--DScrollBar::handle:horizontal{ min-width: 20px; height: 8px; } Dtk--Widget--DScrollBar::handle:hover{ background-color: rgba(255,255,255,0.4); } Dtk--Widget--DScrollBar::add-line { border: none; background: none; } Dtk--Widget--DScrollBar::sub-line { border: none; background: none; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DSearchEdit.theme000066400000000000000000000016611325435343100255560ustar00rootroot00000000000000Dtk--Widget--DSearchEdit { border-radius: 4px; } Dtk--Widget--DSearchEdit #SearchIcon { background-color:transparent; margin: 2 -1 2 4 px; border-image:url(:/images/dark/images/search.svg); } Dtk--Widget--DSearchEdit #ClearIcon { background-color:transparent; qproperty-normalPic:url(:/images/dark/images/input_clear_normal.svg); qproperty-hoverPic:url(:/images/dark/images/input_clear_hover.svg); qproperty-pressPic:url(:/images/dark/images/input_clear_press.svg); } Dtk--Widget--DSearchEdit #Edit { background-color:transparent; border-radius:0; color:#fff; padding-right:15px; padding-bottom: 1px; } Dtk--Widget--DSearchEdit QFrame#DEditInsideFrame { background-color: rgba(255,255,255,15%); border: 0px solid; border-radius: 4px; border-color: rgba(0, 0, 0, 0.08); } Dtk--Widget--DSearchEdit #PlaceHolder { color:white; margin:0 0 0 3px; font-size:12px; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DSegmentedControl.theme000066400000000000000000000014301325435343100270110ustar00rootroot00000000000000Dtk--Widget--DSegmentedControl#DSegmentedControl{ border: 1px double black; border-radius: 3px; border-bottom-color: #22FFFFFF; background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #191919, stop: 0.2 #1e1e1e, stop: 1 #1e1e1e); min-height: 21px; max-height: 21px; } Dtk--Widget--DSegmentedControl Dtk--Widget--DSegmentedHighlight#Highlight{ background-color: #101010; } Dtk--Widget--DSegmentedControl QToolButton#Segmented:enabled{ color: #C0C0C0; padding-bottom: 2px; } Dtk--Widget--DSegmentedControl QToolButton#Segmented:hover{ color: white; } Dtk--Widget--DSegmentedControl QToolButton#Segmented{ background: transparent; color: #19A9F9; font-size: 12px; border: none; padding-bottom: 2px; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DSeparatorHorizontal.theme000066400000000000000000000004201325435343100275450ustar00rootroot00000000000000Dtk--Widget--DSeparatorHorizontal QWidget#DSeparatorTopRec { background-color: #99000000; min-height: 1; max-height: 1; } Dtk--Widget--DSeparatorHorizontal QWidget#DSeparatorBottomRec { background-color: #0cffffff; min-height: 1; max-height: 1; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DSeparatorVertical.theme000066400000000000000000000004101325435343100271640ustar00rootroot00000000000000Dtk--Widget--DSeparatorVertical QWidget#DSeparatorLeftRec { background-color: #99000000; min-width: 1; max-width: 1; } Dtk--Widget--DSeparatorVertical QWidget#DSeparatorRightRec { background-color: #0cffffff; min-width: 1; max-width: 1; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DSettingsDialog.theme000066400000000000000000000040451325435343100264620ustar00rootroot00000000000000#DSettingsDialog{ qproperty-backgroundColor: white; qproperty-borderColor: rgba(0, 0, 0, 0.2); } #Navigation{ border: none; border-right: 1px solid rgba(0,0,0,0.1); } #NavigationBar{ border: none; } #ButtonGroupSingle { border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 4.0px; } #ButtonGroupBegin { border: 1px solid rgba(0, 0, 0, 0.08); border-top-left-radius: 4.0px; border-bottom-left-radius: 4.0px; } #ButtonGroupBegin:checked { background-color: #2ca7f8; border: solid 1px rgba(0, 90, 224, 0.22); } #ButtonGroupMiddle { border-top: 1px solid rgba(0, 0, 0, 0.08); border-bottom: 1px solid rgba(0, 0, 0, 0.08); border-right: 1px solid rgba(0, 0, 0, 0.08); } #ButtonGroupMiddle:checked { background-color: #2ca7f8; border: solid 1px rgba(0, 90, 224, 0.22); } #ButtonGroupEnd { border: 1px solid rgba(0, 0, 0, 0.08); border-left: none; border-top-right-radius: 4.0px; border-bottom-right-radius: 4.0px; } #ButtonGroupEnd:checked { background-color: #2ca7f8; border: solid 1px rgba(0, 90, 224, 0.22); } #SettingsContentReset { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFFF, stop:1 #FBFBFB); border-color: rgba(0, 131, 255, 0.4); border-radius: 4; border-style: solid; border-width: 1; outline: none; padding: 3px 24px 4px 24px; color: #0699ff; font-size: 14px; } #SettingsContentReset:hover { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #8ccfff, stop:1 #4bb8ff); color: #FFFFFF; border-color: rgba(0, 117, 243, 0.2); } #SettingsContentReset:pressed { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #0b8cff, stop:1 #0aa1ff); color: #FFFFFF; border-color: rgba(29, 129, 255, 0.3); } #DSettingsDialogClose{ qproperty-normalPic: url(:/images/light/images/window/close_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/close_hover.svg); qproperty-pressPic: url(:/images/light/images/window/close_press.svg); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DShortcutEdit.theme000066400000000000000000000004461325435343100261640ustar00rootroot00000000000000 Dtk--Widget--DShortcutEdit { border-radius:4px; } Dtk--Widget--DShortcutEdit #Edit { color:#fff; background-color:#2f2626; padding:4px 3px; } Dtk--Widget--DShortcutEdit #Label { qproperty-echoNormal:black; qproperty-echoHover:red; qproperty-echoInvalid:orange; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DSlider.theme000066400000000000000000000033231325435343100247620ustar00rootroot00000000000000Dtk--Widget--DSlider { qproperty-tipColor: #505050; qproperty-scaleColor: #505050; qproperty-hoverValueColor: #B4B4B4; } /*************************************For Round Handle***************************************/ Dtk--Widget--DSlider::groove[handleType="1"] { margin-left: 10px; margin-right: 10px; border-width: 0px 2px 1px 2px; border-image: url(:/images/dark/images/slider_bg.png) 0 2 1 2 stretch; height: 8px; } Dtk--Widget--DSlider::handle[handleType="1"] { background: url(:/images/dark/images/slider_handle.svg); width: 18px; height: 18px; margin-top: -5px; margin-bottom: -5px; margin-left: -10px; margin-right: -10px; border-radius: 6px; } Dtk--Widget--DSlider::add-page:horizontal[handleType="1"] { border-width: 0px 2px 1px 2px; border-image: url(:/images/dark/images/slider_bg.png) 0 2 1 2 stretch; margin-right: 10px; height: 8px; } Dtk--Widget--DSlider::sub-page[handleType="1"] { border-width: 0px 2px 0px 2px; border-image: url(:/images/dark/images/slider_bg_active.png) 0 2 0 2 stretch; margin-top: 1px; margin-bottom: 2px; margin-left: 10; height: 6px; } /*************************************For Sharp Handle***************************************/ Dtk--Widget--DSlider::groove[handleType="0"] { margin-left: 9px; margin-right: 9px; border-width: 0px 2px 1px 2px; border-image: url(:/images/dark/images/slider_bg.png) 0 2 1 2 stretch; height: 8px; } Dtk--Widget--DSlider::handle[handleType="0"] { background: url(:/images/dark/images/slider_balance.png); width: 16px; height: 20px; margin-top: -6px; margin-bottom: -6px; margin-left: -9px; margin-right: -9px; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DSpinBox.theme000066400000000000000000000016461325435343100251300ustar00rootroot00000000000000QAbstractSpinBox { min-height: 22px; color: #fff; border-radius: 3; padding-right: 53px; background-color: rgba(255, 255, 255, 26);/*use as outside border*/ } QFrame#SpinBoxInsideFrame {/*outside frame*/ background-color: rgba(0, 0, 0, 50); border: 1px solid black; border-radius: 3; } #SpinBox_ImageButton { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #50333333, stop: 1.0 #50000000); border-left: 1px solid #AA111111; } QAbstractSpinBox[alert="true"] QFrame#SpinBoxInsideFrame{ border-color: #FF8F00; } QAbstractSpinBox::up-button { border: none; background: transparent; } QAbstractSpinBox::up-arrow { border: none; background: transparent; } QAbstractSpinBox::down-button { border: none; background: transparent; } QAbstractSpinBox::down-arrow { border: none; background: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DStackWidget.theme000066400000000000000000000000721325435343100257470ustar00rootroot00000000000000Dtk--Widget--DStackWidget{ background: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DSwitchButton.theme000066400000000000000000000005531325435343100261770ustar00rootroot00000000000000Dtk--Widget--DSwitchButton#DSwitchButton{ qproperty-enabledImageSource: ":/images/dark/images/switch_inner.png"; qproperty-disabledImageSource: ":/images/dark/images/switch_inner_insensitive.png"; qproperty-animationStartValue: -20; qproperty-animationEndValue: 0; qproperty-animationDuration: 150; qproperty-animationType: InOutQuad; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DTextButton.theme000066400000000000000000000011021325435343100256510ustar00rootroot00000000000000Dtk--Widget--DTextButton { padding:0 5px; min-width:50px; color: #CCCCCC; outline:none; border-width:5px 5px 5px 5px; border-image:url(:/images/dark/images/dark_button_normal_bg.png) 5 5 5 5 stretch; background-color:transparent; } Dtk--Widget--DTextButton:hover { color: #AAA; border-image:url(:/images/dark/images/dark_button_hover_bg.png) 5 5 5 5 stretch; } Dtk--Widget--DTextButton:pressed { border-image:url(:/images/dark/images/dark_button_press_bg.png) 5 5 5 5 stretch; } Dtk--Widget--DTextButton:checked { color:#01BDFF; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DTextEdit.theme000066400000000000000000000006111325435343100252670ustar00rootroot00000000000000Dtk--Widget--DTextEdit { color: #fff; border-radius: 3; background-color: rgba(255, 255, 255, 26);/*use as outside border*/ } Dtk--Widget--DTextEdit[alert="true"] QFrame#TextEditInsideFrame{ border-color: #FF8F00; } QFrame#TextEditInsideFrame {/*outside frame*/ background-color: rgba(0, 0, 0, 50); border: 1px solid; border-radius: 3; border-color: black; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DTitlebar.theme000066400000000000000000000014641325435343100253120ustar00rootroot00000000000000Dtk--Widget--DTitlebar { background: qlineargradient(x1:0 y1:0, x2:0 y2:1, stop:0 rgba(0,0,0,85%), stop:1 rgba(0,0,0,85%)); } Dtk--Widget--DTitlebar[transparent=true] { background: transparent; } Dtk--Widget--DWindowCloseButton { qproperty-normalPic: url(:/images/dark/images/window/close_normal.svg); qproperty-hoverPic: url(:/images/dark/images/window/close_hover.svg); qproperty-pressPic: url(:/images/dark/images/window/close_press.svg); padding-right: 6px; } #DTitlebarDWindowQuitFullscreenButton { qproperty-normalPic: url(:/images/dark/images/window/quit_fullscreen_normal.svg); qproperty-hoverPic: url(:/images/dark/images/window/quit_fullscreen_hover.svg); qproperty-pressPic: url(:/images/dark/images/window/quit_fullscreen_press.svg); padding-right: 6px; } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DToast.theme000066400000000000000000000001751325435343100246340ustar00rootroot00000000000000Dtk--Widget--DToast { border: 1px solid rgba(0,0,0,10%); border-radius: 4px; background: rgba(49,49,49, 100%); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DWindowCloseButton.theme000066400000000000000000000005241325435343100271710ustar00rootroot00000000000000Dtk--Widget--DWindowCloseButton { qproperty-normalPic: url(:/images/dark/images/window/close_normal.svg); qproperty-hoverPic: url(:/images/dark/images/window/close_hover.svg); qproperty-pressPic: url(:/images/dark/images/window/close_press.svg); qproperty-disabledPic: url(:/images/dark/images/window/close_disabled.svg); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DWindowMaxButton.theme000066400000000000000000000013521325435343100266510ustar00rootroot00000000000000Dtk--Widget--DWindowMaxButton[isMaximized=true] { qproperty-normalPic: url(:/images/dark/images/window/unmaximize_normal.svg); qproperty-hoverPic: url(:/images/dark/images/window/unmaximize_hover.svg); qproperty-pressPic: url(:/images/dark/images/window/unmaximize_press.svg); qproperty-disabledPic: url(:/images/dark/images/window/unmaximize_disabled.svg); } Dtk--Widget--DWindowMaxButton[isMaximized=false] { qproperty-normalPic: url(:/images/dark/images/window/maximize_normal.svg); qproperty-hoverPic: url(:/images/dark/images/window/maximize_hover.svg); qproperty-pressPic: url(:/images/dark/images/window/maximize_press.svg); qproperty-disabledPic: url(:/images/dark/images/window/maximize_disabled.svg); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DWindowMinButton.theme000066400000000000000000000005361325435343100266520ustar00rootroot00000000000000Dtk--Widget--DWindowMinButton { qproperty-normalPic: url(:/images/dark/images/window/minimise_normal.svg); qproperty-hoverPic: url(:/images/dark/images/window/minimise_hover.svg); qproperty-pressPic: url(:/images/dark/images/window/minimise_press.svg); qproperty-disabledPic: url(:/images/dark/images/window/minimise_disabled.svg); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DWindowOptionButton.theme000066400000000000000000000005211325435343100273710ustar00rootroot00000000000000Dtk--Widget--DWindowOptionButton { qproperty-normalPic: url(:/images/dark/images/window/menu_normal.svg); qproperty-hoverPic: url(:/images/dark/images/window/menu_hover.svg); qproperty-pressPic: url(:/images/dark/images/window/menu_press.svg); qproperty-disabledPic: url(:/images/dark/images/window/menu_disabled.svg); } dtkwidget-2.0.7.2/src/widgets/themes/dark/Dtk--Widget--DWindowRestoreButton.theme000066400000000000000000000004251325435343100275470ustar00rootroot00000000000000Dtk--Widget--DWindowRestoreButton { qproperty-normalPic: url(:/images/dark/images/window/unmaximize_normal.svg); qproperty-hoverPic: url(:/images/dark/images/window/unmaximize_hover.svg); qproperty-pressPic: url(:/images/dark/images/window/unmaximize_press.svg); } dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/000077500000000000000000000000001325435343100217365ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/000077500000000000000000000000001325435343100232035ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/check_focus.png000066400000000000000000000003251325435343100261650ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(cdhT^@6alϯ _gf+fb2`XXp{[lTf224|W1=L`g2D̄,F {xhE (ZfTU-??W70>XԤe?tIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/dark_check.png000066400000000000000000000003071325435343100257670ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(͒1 E[/ .;p2b7kKC3ԳARJ>jW̑!2s~N9Wlg-:p`ۑ=>O l`1㭈92d :2 IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/dark_check_checked.png000066400000000000000000000005171325435343100274400ustar00rootroot00000000000000PNG  IHDR Vu\sRGB IDAT(c?# 1+coZb###V eڠx.Ӂ~}l+> &LHa9 xyyY`l]]]fbb/01'L:5&Q^^hii}apSϝ;wݽlҤI>|x&KKKhA9::ے7$@6b&-гA 3Ɂ߂l )ie}saIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/dark_check_checked_hover.png000066400000000000000000000006701325435343100306430ustar00rootroot00000000000000PNG  IHDR Vu\sRGBrIDAT(c````ebabb|ddžAr 5 @F]eB.n1@-@)$c^_94][ܢ@@E |j߯R2>P糽~yʠ^Rab102Xb@J{KXyY!f5010ܘQpwQ= V|l=íy5 Y`19v~ W n̬`KaP.Hu63\/:?wzj-J Lau/>޼ȠU598%+?X??°E=3M¯7sf#0(@z ' K}z|& y`I}~1IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/dark_close_small_hover.png000066400000000000000000000003261325435343100304130ustar00rootroot00000000000000PNG  IHDRVsRGBIDATH R 0,}C,>}Ð%~-Krox<#1@j@)7]Ϡl^YzI" 2*c3Y3Yj aw|cIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/dark_close_small_press.png000066400000000000000000000003261325435343100304240ustar00rootroot00000000000000PNG  IHDRVsRGBIDATH R;0rsvpv>,~ C[x=Rwy\k{yTt]^ 6}^w,,pPh""W)ImhD+lR#a Zw@9B$LIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/dark_minimise_small_hover.png000066400000000000000000000002111325435343100311110ustar00rootroot00000000000000PNG  IHDR霝sRGBCIDATH c`!0!0B TEPD6gFo|jI,?zF5h8HLIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/dark_minimise_small_normal.png000066400000000000000000000002161325435343100312630ustar00rootroot00000000000000PNG  IHDR霝sRGBHIDATH 1 @t,=@XIY[8(@v>R `f1uGVwWwا(@ a(IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/dark_minimise_small_press.png000066400000000000000000000002121325435343100311230ustar00rootroot00000000000000PNG  IHDR霝sRGBDIDATH c`!0!0BNne`d"m ̽e'I2j  )~IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/dialogs/images/user-trash-full.png000066400000000000000000000036621325435343100267550ustar00rootroot00000000000000PNG  IHDR00WsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org</IDAThmpTW}f߲ !I"fHu:% t8NGqPEbP&qDQ0qݘ}9~Hnt?sΞ{<<ϽpO-qLV9!BueYJ)E R!kR^,R^B,ˊ=@DJ1M|<?q+CCC !5o*xoDI(_͈5F͇*;5ID9Hg613@`"Dd_ ~~tj bլ"~~pu~N:nd7l66I(uﻜaWh+ u';nxXsߗ'8ݍlulWi6G*m*Kpo5R婼nl# iy[٘QӮ@i1xrB['" `z\ݏWW|o_aMʂeSŀ Sh kٙ_Rbo5g]T'sglFuA%A{!} !.Y}?^ ?w_Ŕ?.33ui/~fM984EO}{F?9&-v^›5 [4?oI }՞0oM.9L<>jYv,}b.ӺllԦhT{OTժT25+[T\KA[2mrm'̨{wZ9 mۚٹs/R^(g`չ4~6nܨK)NH$ii90%ٵd2se]d>XQJy1cuL\<ȑnjɲHd535X `1ZRN-cn'|&&,jv IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/000077500000000000000000000000001325435343100215615ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/dark/images/add_hover.png000066400000000000000000000012531325435343100242230ustar00rootroot00000000000000PNG  IHDRj cHRMz%u0`:o_FPLTE...;::<;;=<<100%%%&&&0//:99$$$###IIIHHH988877"""!!!766 444000655544///---433322211&%%%$$,q tRNS&&U6bKGDA pHYs  IDATeʋR0lJG%*цEL(ߜ8cOt @[;^SvJ0AFF vT&)Kd,$##e.y%sU*T ^)-de 8l(o*sT.O! ><IVrb|֟mv5ײ]&XERn,ؚC;%息%tEXtdate:create2014-06-20T14:58:50+08:00Z%tEXtdate:modify2014-06-20T14:58:50+08:00zIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/add_normal.png000066400000000000000000000012371325435343100243720ustar00rootroot00000000000000PNG  IHDRj cHRMz%u0`:o_FPLTE...;::<;;=<<100%%%&&&0//:99$$$###BBBAAA988877"""!!!766 000---655544,,,***433322211&%%%$$ tRNS&& pHYs  IDAT]ʍR@f"GbqQkg3,,۶lkkٻ{prw$ ttXE!Ȓ*SBӳL't8^2OQ~hJi==)))?>>***+++A@@,,,@??BAA---CBB...DCC///000EDD111999333222:::GFFHGGtRNS&&@ pHYs  %IDATeȋV@ၲoemf2ʼevAd)Jc'#CpQr~P=rSbIxRjR#UޓZZ]{uC7OϚ_|~5k(gfoہΛeZ&EΖOWۯhπ6؎mGc3vȐ!4Q)ٚ: /bI݋y"QiC4]Ъl%tEXtdate:create2014-06-20T14:58:52+08:00J%tEXtdate:modify2014-06-20T14:58:52+08:00;SIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_down_hover.png000066400000000000000000000002241325435343100256510ustar00rootroot00000000000000PNG  IHDRxUsRGBNIDATc)}FF5@n@-xK!0YF #X (?A@@K`aJTuLB K=,#IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_down_hover.svg000066400000000000000000000011571325435343100256720ustar00rootroot00000000000000 down_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_down_insensitive.svg000066400000000000000000000012211325435343100270770ustar00rootroot00000000000000 down_insensitive Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_down_normal.png000066400000000000000000000002451325435343100260210ustar00rootroot00000000000000PNG  IHDRxUsRGB_IDATcw^)}%%5@n@-x@,Tr#$H* ~bd-  Ew q L)B1\0tyIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_down_normal.svg000066400000000000000000000011611325435343100260320ustar00rootroot00000000000000 down_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_down_press.png000066400000000000000000000002671325435343100256710ustar00rootroot00000000000000PNG  IHDRxUsRGBqIDATc[񣔁05 H@o2100aު!0y622[+LL ь>$^+@VLf"G \r46 IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_down_press.svg000066400000000000000000000011571325435343100257030ustar00rootroot00000000000000 down_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_down_white.png000066400000000000000000000003711325435343100256510ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?%q `@ 5P`>qy#G\gHn\4Gd@x.Ch^C |a>͸ @1f|:B iNIy 0\ IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_left_hover.png000066400000000000000000000004431325435343100256370ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?1BCHlH̙3߹sǟdf(^@hi@fY,L3M(Ѐe۷R 6SAΆ1LȆ,\<#4w.RG0qr>`\k"IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_left_normal.png000066400000000000000000000005011325435343100257770ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?1BCHyxx˱0aaajjjLj.؅D`asssQhj@RRYiii#ӧ͛g/02W)40]A[nXjD k^ %KA Al$%e4C 1bGR ]2TNIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_left_press.png000066400000000000000000000004431325435343100256500ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?1BCHlH̙3߹sǟdf(^@hi@fY,L3M(Ѐe۷R 6SAΆ1LȆ,\<#4w.RG0qr>`\k"IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_left_white.png000066400000000000000000000004261325435343100256350ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?1,CHgޡRH Gd} @  68 V3VHьՀׯ鄲xc}V1a+@yh/jDb2ܐg'+/ Er  @g&@~_ݠZIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_right_hover.png000066400000000000000000000004721325435343100260240ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?2 ADž1RA, h`ƍ. E wYAx̙  )4XC1 5k֜b3 ``,T}V 700L0T0A!: ՌR4c5`… ŒP[ۗt̅ bs# H;AaOIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_right_normal.png000066400000000000000000000005261325435343100261710ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?2 ADž1xxxRA, h %%hx>###HQ.Լ DI g#(voݺbժUqb k$%%6>}zn޼yxt`~U th/4bP D@f111Uь5~XH%5O` L@A|SYGHIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_right_press.png000066400000000000000000000004721325435343100260350ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?2 ADž1RA, h`ƍ. E wYAx̙  )4XC1 5k֜b3 ``,T}V 700L0T0A!: ՌR4c5`… ŒP[ۗt̅ bs# H;AaOIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_right_white.png000066400000000000000000000004311325435343100260140ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?2 @Dž1TTT gϞhHY{>ȑ Mp( \DyDB(B0_f"Ā022}Vxg rX@thjٳgHf\a FF IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_up_hover.png000066400000000000000000000002101325435343100253210ustar00rootroot00000000000000PNG  IHDRxUsRGBBIDATc`@d$!*H $+@q6## djqE0IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_up_hover.svg000066400000000000000000000013031325435343100253400ustar00rootroot00000000000000 up_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_up_insensitive.svg000066400000000000000000000013451325435343100265630ustar00rootroot00000000000000 up_insensitive Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_up_normal.png000066400000000000000000000002371325435343100254770ustar00rootroot00000000000000PNG  IHDRxUsRGBYIDATc`@ d$!$@>#ͨ4$"`@T8(cA1L  @:a ]@X4H 2'IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_up_normal.svg000066400000000000000000000013051325435343100255070ustar00rootroot00000000000000 up_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_up_press.png000066400000000000000000000002541325435343100253420ustar00rootroot00000000000000PNG  IHDRxUsRGBfIDATMA 0 Q7=E_Cb+(og8HCA!ȐMahL' ޺Tз&v{0V#IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_up_press.svg000066400000000000000000000013031325435343100253510ustar00rootroot00000000000000 up_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/arrow_up_white.png000066400000000000000000000003531325435343100253260ustar00rootroot00000000000000PNG  IHDRa pHYs  tEXtSoftwareAdobe ImageReadyqe<xIDATxb?%qpj6RÂO#Gl܆\(AbXLB@1NCi4f\X [ @ hF6T`Ot1 NvcSCIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/button_center_normal.png000066400000000000000000000017221325435343100265140ustar00rootroot00000000000000PNG  IHDRetEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp }NEIDATxbcdddQ_|a```bxP ,E >rX H1)-pIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/button_center_press.png000066400000000000000000000017311325435343100263600ustar00rootroot00000000000000PNG  IHDRetEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp EQLIDATxd1 PC:; ~N"|f $/AAD63#.uFCE ?w]Uvxe H 6IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/button_left_normal.png000066400000000000000000000021161325435343100261640ustar00rootroot00000000000000PNG  IHDRtEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp +IDATx|Q[ \iJ}O=Ky/6PwK@7)L;<_w_5 CDu 4%MӀ>$C ˒``n[1XjEV["`Xy\SqKa{Y I@;)981fu(;a9C۶gT_}) m:IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/button_left_press.png000066400000000000000000000021331325435343100260270ustar00rootroot00000000000000PNG  IHDRtEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp IDATxڄQ @ i!A':K7T ] }0Jk^ֶ~˲,=UUdY&f2cّ lC9 IDATxڜRK @ M.,<{W@u7=N/P DwrIDATxڌA 0E'1"uNp@u7=N/PzEPQ!Lk!8Vs*_~<1#5M#KtcLR;G0Y ]qN _aEӸkLL yn?t*ozoly e‚0~p0pXmȳgL?L>өZ#nz=ct:Z-8þ)$i`4mc6!c<,&{F#K Gafb޳u:yvHlW!ڲO~nS勢xK0MZi%g|nTUyH3 ϔX?_6qpIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/checkbox_checked_hover.png000066400000000000000000000007551325435343100267350ustar00rootroot00000000000000PNG  IHDR Vu\ pHYs  IDAT(RM(DQM=3A~j7H6ذca#E( dge1 YZIXL6$jXH"k4xo9ҭsNν /S~ b4nu݈D=j!~f2 l&mjp"Mު 4]@Jң5B7vf_lmlIBN)oBAU5WI Vu>d.'p å/gt'{8X-\f\R'6Wpd1nSK(1M- h/n>g yA ԩn`K);(Eh|M!'("i cϗ~_ rtlr<ߢ ".0@$^37eYi|=z:͔IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/checkbox_checked_insensitive.png000066400000000000000000000005571325435343100301520ustar00rootroot00000000000000PNG  IHDR Vu\ pHYs  !IDAT(j@EgyXUk b!buzGI>%XXZ"Nbb MfYgwV(xbSBwoeY~߫2yp?[۶)˲0W e˲#1_qw`g0 )sc``YyGia) @]ױ |gmi6JG4MY3IPq]lGa|-tTE4 _L+).?wpȎ8V@?O9ƌu&SIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/checkbox_unchecked.png000066400000000000000000000004531325435343100260700ustar00rootroot00000000000000PNG  IHDR Vu\ pHYs  IDAT( 0 EAL8T*puN8P?Z@Od<;&`X]חu],=Ȃ5M˲iBd-1s[.N>c-L^a躔3]-~&T=Y}lZŇa;FX>!Z Z6|%`\Us ۛRՖߺ {,7#V =O=WsDIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/checkbox_unchecked_insensitive.png000066400000000000000000000004161325435343100305070ustar00rootroot00000000000000PNG  IHDR Vu\ pHYs  IDAT(A EqxV{C5 ".1PFvfxR$c%/R[Y/|&o~Iaι~}y,;CQm[8rEP0 SFaFr?d6\uN8&臙rMxc ' ,Z8\كkOkIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/clear_white.png000066400000000000000000000005121325435343100245530ustar00rootroot00000000000000PNG  IHDR;mG pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb? 6ܽ{)%a߿@ h ٳgi(s> (=M@@e;wC$Ѓ. 0Jѹ,ıgĖؐGuuuR b+VXXom>a'Az0„Q·Cqxb ̟eT^IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/combobox_down_arrow.png000066400000000000000000000005521325435343100263420ustar00rootroot00000000000000PNG  IHDR tggAMA a cHRMz&u0`:pQ<bKGD̿tIME {a𣷟(d2Eȡjj6,g[Δw ٩]箪`$3$۶Mlv l``>S53%Yc2֚ 1"wǒ`HcFǐ缿!yukWFAp_TRW;R5#^O1|qy9 %z_9B*Oczq*+RN]Ű}\EbgL("b{L< +@vSP.Q4c>Il?NEQEγ, <`0Q֓K[)3Of]Yይ+.֙Co#[/{IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/dark_button_press_bg.png000066400000000000000000000007641325435343100264760ustar00rootroot00000000000000PNG  IHDR连sRGBIDAT8N`RG1)O89.n>>a Pi-_s.sҔ8*CV^?<5Klni84=7m6hX, Nm%X#aӢ't:~2|'fzZh(H|vG$  L"9< ZԘ45 }}J2L)35|DP2?#r!Ɣ$\kk(uP`!J0+ȈFEE-`?Ai2>"\*5Lwx~Ny|T跴K{@ZfzfY%",;NWO7x.Liw埕Fm_3ϭD::IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/delete_hover.png000066400000000000000000000010241325435343100247310ustar00rootroot00000000000000PNG  IHDRngAMA a cHRMz&u0`:pQ<bKGD̿ pHYs  IDAT(ύQJ@YBEK ަGi@SX  f#NH37J! ~'Φa7 'Ǔ.i8 $Y0ܼ"0/Q0#Xx2@[!D(]PF:[XK!KhJ@L,DP(k*z,v@C'sG)& ֡4K>W4w|}4e^/9s8R`^VG-Dj]v?N5hN%tEXtdate:create2014-06-20T14:58:52+08:00J%tEXtdate:modify2014-06-20T14:58:52+08:00;SIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/delete_multi_hover.png000066400000000000000000000010411325435343100261420ustar00rootroot00000000000000PNG  IHDRasRGBIDAT8S=HBQ>RJQ$Ԑ`EnE ACcRC{ n4`'QIPZ>^{"Hw}{a)g X\N3\S>o?U<6LdjkɎ,]©r0Cd5Udwt:?Q4К(CHfu=r_gAmcɪ9ss@ Jb]o{=E5nec&ҁ5`Qf(gFٿUIXhq8s,.\C4d+_&Q2SZJ-u12~vHD TDU]Mڞ(.*I>*`!8 &P0U8̅Ғ$0LOD5B :Gd?8{89cХ;sZcI`w_\. [8c7^,TSO>dߺIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/delete_multi_normal.png000066400000000000000000000007671325435343100263250ustar00rootroot00000000000000PNG  IHDRasRGBIDAT8S=OPQ 1Ä0VAfGG63$881M{6&}n=OT3鳖<68-koIQ%tؑH$4R~bi5O]qX@Τkrq7>o&g"~:ޅj쥠nyJ-bifDo FOm$rȖ>X vl< 5,8B Fٿ   I/9vQF`q~V{5P1H~VKD)Y*hAg;>!%k7f.pQA&A `u8 &A'0.Z'e|+nh g3\_z?|\cPeboi.U9:~IĜӱIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/delete_multi_press.png000066400000000000000000000010561325435343100261610ustar00rootroot00000000000000PNG  IHDRasRGBIDAT8SMkQ&Q;LaJAH(Eą-)\ ݸ ?(tiR-BAh4mMaH2d^gJxM;=OgSMK9o4-vbg+zWWȔNnyt,p:X@N;1g Fe]?4?3}g8LzR|rLTI7[nQ`b.rpLt]j #Um6EСUm*+-Z22;KF "/$רw=gE[8c7d; ~s>҇+IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/delete_normal.png000066400000000000000000000010071325435343100250770ustar00rootroot00000000000000PNG  IHDRn cHRMz%u0`:o_FbKGD̿ pHYs  IDAT(υMj1 ?(!d?WBmr]B:tu1v3N+,= ?=Y`^k[7@05Ժme^*x#,Ar8B'O# % #9]k==)))?>>***A@@,,,+++@??BAA---CBB...DCC///000EDD111999333222:::GFFHGGtRNS&&@ pHYs  IDATe S@e)>XR#B $2-M3|Ӳ͙@*\+9RUEUT%Q%9vS=EuJ57cF)U/Qog4ߙipn[v´MnZh=8\uv #9pˑwf#]yN%E 00 {/[ph<}LO?3:+cyX 8S< +YlR1ݞݶ(Rl($4rOl%tEXtdate:create2014-06-20T14:58:51+08:00{-r%tEXtdate:modify2014-06-20T14:58:51+08:00 pIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/dock_preview_close_hover.png000066400000000000000000000022221325435343100273360ustar00rootroot00000000000000PNG  IHDRsRGBLIDAT8U{L[e?_{ ڂqC!fJ=s6l ffdb4QFc1#nhdq Scftڍ( r{n%hHԯ圞{_9~e+)@f[0J$!^,+/_zw' *}co>62000 i2y%[kV!IĬut,Z['! P f\u>ܓ?2qxG YB>EWo|b%< Nݾil!S+TUK3!9zxs% 1UT2Sl*! GIk^l.ӿkMGX$ M!0e4p[*GNxĔL_Jib5MP!>ܞC,ceK;{]ԲЮݧv.JUet:TYɤ.@nkBr2/ Әȸc)(0Bc)S#2z=%XL&nsU6e2* +;Y?f{B`>vpkJVofy J O껛KRtUQトFq S><sj%gI S_wCcub"m> l[ 0TNv]яǶs]ºU;Dr{'{2 É/^n1Od<1Lr''>A`$L{)>).i]Jt{z&LΔ02 eB>E*swG\飕(#Ctp-"1ptUH~"j/+ʮ.NRUwc ׇ'H͐ 3gj tʌ :GGɤ0q~ I"f_<''#,Vy]|X.Г;Ҋ,S}?yɜX&E$΁/y^I uI, BTqUeۨhNt5p-dL/.;?r z'\ )E(ͤUi6O jE+c9rl?H'4IE*3w%* 3m1ūRr"85cg輪:Eqkt..uЯ&z. P%,A/yD1Yy k׻mYY^!12C|mVm~Xq)y觟WN 9˾SnLJ rtP728# oluqA w\XrX,R.]M@F1M _ֽI^\?Sm+0//{;ҬKҪ4 ||ϝ_#6{9\IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/file_24.png000066400000000000000000000060411325435343100235140ustar00rootroot00000000000000PNG  IHDRw= pHYs   MiCCPPhotoshop ICC profilexڝSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/%ҟ3 cHRMz%u0`:o_FNIDATxԖ1n@E.KJڮFrWRn| !9 71AB̤0HVEFJDU"VJ)m^s6P{<r zP/@kfY ]{O>|vlKk"*D|Cns.Y,"ʕR{?HnC2UUH4neo""V-r}߿0h(X׵'qeY渓:}젮koC'o9`f A-"u cha8'tzyDNnqm ͹U*!A^ضrIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/folder_24.png000066400000000000000000000062211325435343100240500ustar00rootroot00000000000000PNG  IHDRw= pHYs   MiCCPPhotoshop ICC profilexڝSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/%ҟ3 cHRMz%u0`:o_FIDATxڴ@#FW^ nL^!0y y?y@\[F0㋴Hff4sfDU3*"r^q<8yH#>c@EUx<SUNcW{P4?sL$~8^[v=[Auk\ UU7Mcft\~O|>t Py~Ej5z_o+T""= 6OYqνrPUUl60u| ( Ƙ9+E,нnMx,c@|nUeEu]"Y=.(r%",F~ 9 C!i1<^$7VKKn8~/K*.lTIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/folder_up_24.png000066400000000000000000000063671325435343100245670ustar00rootroot00000000000000PNG  IHDRw= pHYs   MiCCPPhotoshop ICC profilexڝSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/%ҟ3 cHRMz%u0`:o_F$IDATxU=A=3YBK !B,vJH*?@D ?@+K+lRbRy?`-R8 l6/@/܁; ̙shqa!deR)Rt:UBRTWJ}^\k=bZIuGJR/<pu7! Q}gyn_0s۶o kX5 a4oFwLbԀbtz\~ LHZVbR;A(BRr΅myIcaǜ_)Bh4{\p@v<b|1Ml%OZpNG8TC @n I˲1 %.IO006xZ 04`8cϦiMPvL|_l ~o őyIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/hide_password_hover.svg000066400000000000000000000015631325435343100263450ustar00rootroot00000000000000 dtkwidget-2.0.7.2/src/widgets/themes/dark/images/hide_password_normal.svg000066400000000000000000000041341325435343100265070ustar00rootroot00000000000000 hide_password_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/hide_password_press.svg000066400000000000000000000012641325435343100263540ustar00rootroot00000000000000 hide_password_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/icon_view_hover.png000066400000000000000000000010741325435343100254560ustar00rootroot00000000000000PNG  IHDR!-sRGBIDATH U;n@]"(@$ P9F6e PٷC#̛t8_F yt.{X.fRl6T&QaZ29t^,V+_*t:U&:'AZr٦9o>$'!.et|ZEɉ̑Y\G҇1W"HvnVzdA8EżTc% pM,[ o\2 9]Ax?ҁ#3?>bXp]ѱمPy |{p5"v> " BшR+1T훁bFhƀsC&H.,mx44)ZN;:'.yT jZI{Z9˵Y0qV$agA߫*0fʮK6p>fOPP(tHA_C^&ɓb=Ky S<ռc]F>?(rkok4_ݹIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/icon_view_normal.png000066400000000000000000000011351325435343100256210ustar00rootroot00000000000000PNG  IHDR!-sRGBIDATH Un"A`!$ ]rB!#Hz) k۴S=5=ݳ/c|bhzl*[/RX,d2iL$1 * ϋuA3L|\9Œa'Dܺ% n1wVdvuu hD@>n}g?Z-:N(A' ;ݤl v]#ɐd#/ x`@kO;@4V؈[ժ;-rW{x"Cb\|'G*p~KFCzIɠZ&džd 0`pDb7$ޅC"rp8+uTN#ǹFy*fR>"<}kB`&雬O@OȤ_0|_7MYd܊ObN 00  ǺtU6xu1&؉0= 8Y*2W^-֢9QL jVv8;Z%^v~զv=} lt`cmJ۟Awsx`:Y峘MVv@KJHfIL`01$iY ^YI6 $-+ &?漞G68#WO>ղ3g   'c J l ⌇e9$Ec)8jCZP^5i &gv3-q/LQߟ޻p{(d$kI$ʁ%WU\RuqǷ/f)H=iɗ͗eodM\HwXwMV&E%їoCVYIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/input_clear_hover.svg000066400000000000000000000026511325435343100260160ustar00rootroot00000000000000 input_clear_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/input_clear_normal.svg000066400000000000000000000026151325435343100261630ustar00rootroot00000000000000 input_clear_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/input_clear_press.svg000066400000000000000000000026261325435343100260310ustar00rootroot00000000000000 input_clear_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/list_view_hover.png000066400000000000000000000010601325435343100254740ustar00rootroot00000000000000PNG  IHDR!-sRGBIDATH UjA]7xCoC\ x!tm$)W9^ra.JϪy[} @ǣ}k|>O{\@n\.EDQ$j5!Sq*KT6q|<8 |by j(ơ-$@[-5unphe` Y& 8 vzĂ0mbJx{o9qrHsj"V+mEˣ= E+MCeE cقt|/|2HѾ"l6WhqؓI" m\Hr(DfĘ\sD Тz>'?"6!!un>ED$I8ɾHrJ9+jjs4{YVbІ(>lCTD֬IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/list_view_normal.png000066400000000000000000000010641325435343100256450ustar00rootroot00000000000000PNG  IHDR}\sRGBIDATH UKjA|\FEΐ뀇I!3d\ .DgpաMOG >hMe#"rR N)G5ăxVCnyDŹX,|d|v;YW I /|WMܫM^]M!WZ"(v+\N5lm牎ǣ({DC\Nfn֘Y5&:z=S;ݮ0Zn}ժ- -" LP(d23.Y4sвi"m}aR=3¢tcI8s tL[Nшt"Z-Ci65 -*ˉGF1 f<s=w" k>V[T*dZY 3s΃cE"Lf%͛ 8o0 %qr= fY T \[Dlr6|M?Ew?rIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/list_view_press.png000066400000000000000000000011331325435343100255060ustar00rootroot00000000000000PNG  IHDR!-sRGBIDATH UJQDg/Zh~6Z~61 "DkN0p=8gf">1iO'3N؜6@ ZfP* IY133w1fOoZh$gW0=gŴi N6H 3Y98 vۣk3S1ԱIr9RK'q&/(<3~g B'$dF|x_{ L hBغy#/H n_6xueR|>Ё]E.sEn /:_)M`״\IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/loadfile_hover.png000066400000000000000000000001741325435343100252530ustar00rootroot00000000000000PNG  IHDRĴl; pHYs  .IDAT8c`!0(aN"ćL0(=!0BIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/loadfile_normal.png000066400000000000000000000001741325435343100254200ustar00rootroot00000000000000PNG  IHDRĴl; pHYs  .IDAT8c`!0(laN"ćL0(=!0BIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/loadfile_press.png000066400000000000000000000001741325435343100252640ustar00rootroot00000000000000PNG  IHDRĴl; pHYs  .IDAT8c`!0(lll0I0u0 GC`4CͰ 5͎IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/multiselect_active_normal.png000066400000000000000000000010471325435343100275260ustar00rootroot00000000000000PNG  IHDRasRGBIDAT8SKP&b[QmEܴ(8* 88(NnN$R(TIWj_Mݻw$-:X{Y5۝5gض"5ldzэhH,͊¯䕘QTld9/E&#NpEzOdb/(juz'Jl>a,Gv£rWp=,hP +Lr dqldv=d- F ba1Ԍcgv^c! `A+OɋYA,.X?ZfSffS.5HZ4_gn|aHt4=N#w`IaHf 8& C>5C1qJB՗%KeӔʢ\\2nٛ) hgs}CI2y!y`{Wm1B9?g{3 q9җrIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/multiselect_inactive_hover.png000066400000000000000000000005161325435343100277100ustar00rootroot00000000000000PNG  IHDRasRGBIDAT8SA 0,|DU|7/}B{PH8wi -d73;$MyVź,Su7c̛Θ{g1۫0IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/radio_selected.png000066400000000000000000000006511325435343100252370ustar00rootroot00000000000000PNG  IHDR Vu\ pHYs  [IDAT(RjP>tp( E!A0soЩSC"s }A!RȐEAPfl:{s:de|<A>N(ﺮ11~DZe10ɲL~,ZH0NKl65l@u: :nbN'9 ] !OՏ#9rѻඖZeINP c!l<8'j;YQ7grg ڦ1<lp&/ԍׇ<>44J5b* v~ɭ3Kh.MxWJPISqpӮ๕aB:g< +ԂFW֎2 ?O{Q7>C]x s-Vj5[)b[U^e2!he)ڸK lN߳fDdYiIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/radio_selected_insensitive.png000066400000000000000000000006411325435343100276560ustar00rootroot00000000000000PNG  IHDR Vu\ pHYs  SIDAT(R1k`/~L""n?sgW,fRYD0h렱 {w/;&^9(+>8+R}t:=fYz&u$ry6 wb{"22 ,ˢp4'E1q4Qj|Ni0,o@3d 1yG^av%`AYV Eo:hGKxy `K\.wÁd&U*v\RBVl~8 xEA7MCr qJTz& 5\ӿ1a8DLIgmz}vc)FVR(1p}82m8_ M9IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/radio_unselected_hover.png000066400000000000000000000007051325435343100270050ustar00rootroot00000000000000PNG  IHDR Vu\gAMA a cHRMz&u0`:pQ< pHYs  ;IDAT(cdٮ`H ҆ _eϰTSaUm_0 K37󿘒III0WVɁԀ40Lp bR5axװ邖89,޵݉\׃4cx&g f&gZ&6ˏ/ LL & `$͂.Gg c d 8@ܫLp쒀Uș g/ LHTt᧊1VM 9Zp"- /b` d=_N^ON  /pp0|b| G$Iq1`>cIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/radio_unselected_insensitive.png000066400000000000000000000005721325435343100302240ustar00rootroot00000000000000PNG  IHDR Vu\ pHYs  ,IDAT(R1k@48 PsgWnN]Y BPU{^HShwywީWDQ8˲p0d&a,ˇyEQlP\(9NH0~Π~@Lh:dj8Ro՛䫐756Gik<\7]檙{g :EEVph{`Q@{ v U7_Z(@w/%:E˥X8ЗaIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/restore_normal.png000066400000000000000000000003671325435343100253300ustar00rootroot00000000000000PNG  IHDR}\sRGBIDATH c`!S LH{Sr-Ђ]@  ^@,@@#3C @' Ԍ!@ ^EC-Ǧ(ğYt90XgLRcC,H>+ᐆ/lJSj*NE I{yoZ3v|Id1deʑb Yh,՝@3tTcIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/search.svg000066400000000000000000000014361325435343100235530ustar00rootroot00000000000000 search Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/search_hover.png000066400000000000000000000005741325435343100247450ustar00rootroot00000000000000PNG  IHDRasBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDAT8/NCAy}O#hHp&ABA&C`PX yy,ٙl$:yDL#=irm"P3ܢ~͒Ytpq8y:9w(V7(5H7ttw'[+#ʭ)"zkz1ϭ(W_&In .Qet{#8J܇E̱4sΎ6䯵Ӏ\PCΰ(l= 4`IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/search_normal.png000066400000000000000000000007731325435343100251130ustar00rootroot00000000000000PNG  IHDRasBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<xIDAT8kA.ĄUN Uqu˝ !1DL)q[*%(5{3{[0yߙ$ƘSm>|CQo4u g$oI!y j:v%lZ?O$*Y8: sBrjZ#95ƜT_IW6ݨ|M Pˆf<8v|soKtZ>n `+<<8/$MG'%Ͼ5NZs0Se$IJe9hLV,6i4eC$Irll腤3I+GW= 9^IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/search_press.png000066400000000000000000000010011325435343100247400ustar00rootroot00000000000000PNG  IHDRasBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<~IDAT81K\AϙHa#)RmN1N|`bEb#iXؤIc-4"))B˲w, o%e;~3Qސtw6Jo$c%58޿ M\s+`Iқ)B83;7Ifcf\;IoѼ@3;o.X'&{KZo]ZWs&jVn,RMu<-3_HxEQ>O3_UU!=ݺߏBx^!$]$wkx  show_password_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/show_password_normal.svg000066400000000000000000000045271325435343100265640ustar00rootroot00000000000000 show_password_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/show_password_press.svg000066400000000000000000000072201325435343100264210ustar00rootroot00000000000000 show_password_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/slider_balance.png000066400000000000000000000360011325435343100252160ustar00rootroot00000000000000PNG  IHDRbw pHYs  9iTXtXML:com.adobe.xmp Adobe Photoshop CC (Macintosh) 2014-03-17T14:50:09+08:00 2014-03-17T14:55:45+08:00 2014-03-17T14:55:45+08:00 image/png 3 xmp.iid:fae3abff-00d9-4875-b330-33f2a5c69225 xmp.did:ca517e6f-2d61-4696-8e7f-678f8d782fd8 xmp.did:ca517e6f-2d61-4696-8e7f-678f8d782fd8 created xmp.iid:ca517e6f-2d61-4696-8e7f-678f8d782fd8 2014-03-17T14:50:09+08:00 Adobe Photoshop CC (Macintosh) saved xmp.iid:fae3abff-00d9-4875-b330-33f2a5c69225 2014-03-17T14:55:45+08:00 Adobe Photoshop CC (Macintosh) / 1 720000/10000 720000/10000 2 65535 16 20 ${ cHRMz%u0`:o_FIDATxڬAj@y3FjMc E/rz,Kt\weǕ&).DM |A)ZsY;,D$ep"j8^vl6!*Yh4"%/!b%8m"5x/z_9?i?sn\.RRhY,8@'{*u/@kMQxwFmGc}]]YB֔eI]ם1mG{qi×$IbUUlsk]8mմm;Ͳ91(hjEߪ{\i:Z~Gg|I_f2 Za}xp9B1}K1/N#f5DzY^.7%Y> AqxJA0]o.GO`_2#^\xfvϫXge5yD"9̨bb~F"N]y/ӃuIJ;%[7Y; h7c?,blsI*p8+;s:<'=S皿1)VVN;Wӣ4'S}ZOY||WiWth2{&AyW"'-yFtW'6IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/slider_handle.svg000066400000000000000000000030571325435343100251040ustar00rootroot00000000000000 dtkwidget-2.0.7.2/src/widgets/themes/dark/images/spinner_decrease.png000066400000000000000000000004521325435343100256010ustar00rootroot00000000000000PNG  IHDR pHYs  IDAT8K0 DIݔMٸ"*X`%d^)#sf# MR24N~ Zm9`ܐaۜQpm@u 229TXݡ/n`UU5Qn!zlÀCbSk.w]k(#Pהw\ /S=Tqu :~vO7c rsIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/spinner_decrease_hover.png000066400000000000000000000003171325435343100270040ustar00rootroot00000000000000PNG  IHDR}\sRGBIDATH c?3 1S|r0-02a*3.2A.PY@`H.4 "D,T$ N1iBԈn.h$ hDVPI+p@MIBd%D`IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/spinner_decrease_normal.png000066400000000000000000000001631325435343100271500ustar00rootroot00000000000000PNG  IHDR}\sRGB-IDATH c`!0!@0ar@cң!01>3wIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/spinner_decrease_press.png000066400000000000000000000003251325435343100270140ustar00rootroot00000000000000PNG  IHDR}\sRGBIDATH c?#/s1S ? <@LMr(LrZ. ld` G-(bA8$vi$. XIP3t4 "PF+V('NJKSsZIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/spinner_increase.png000066400000000000000000000003421325435343100256150ustar00rootroot00000000000000PNG  IHDR pHYs  IDAT8c`31TUUXYY=z5!,W2u g"To # tY >0,#W-F|7YdE@ 0Q(Auuu L)Tw!12!%fIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/spinner_increase_hover.png000066400000000000000000000003361325435343100270230ustar00rootroot00000000000000PNG  IHDR}\sRGBIDATH c?3 1S|r0-02a*3.2A.PY@`H.4҂xyP0 }/&,B`286A TD`PcԂKdzTw e3PiRa9/PIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/spinner_increase_normal.png000066400000000000000000000002101325435343100271570ustar00rootroot00000000000000PNG  IHDR}\sRGBBIDATH c`!@XDbrԎZ@0 %BYDˑb)H&4".U0C. SIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/spinner_increase_press.png000066400000000000000000000003421325435343100270310ustar00rootroot00000000000000PNG  IHDR}\sRGBIDATH c?#/s1S ? <@LMr(LrZ. ld` +~>p#=R"r46sZMR\aS?`HDVVN 5&>p"0IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/switch_inner.png000066400000000000000000000010051325435343100247570ustar00rootroot00000000000000PNG  IHDR: DssRGBIDATX cd?bCGl<\P@|1M#-=zowe>fi_ #[l4ZK?,'A&"O'@LuDu*Mk];N3fOt)pj0ླྀ Ɣ^nu{0` 4R)Co79:=O!`УK wPsﶤ2cfwp[ 9U4gaЖ6Rreho^BLu"P ;ϔypë$[Q7ky 5{/YzvDdUh7N;17tWHbI̛%;iL>`%oY%WKYi#o( +ʝLi.H.K\ư>[g%oB|Ҟ[/>#5"R9 s;gC̥J*Who KnIUg@~g yC1=Y8 ]3hbI,6Jk_ CGL3=&q^1 czg˄5Pؕ0A> qYYL*~Me)?|Zu22c(o{<bMRHf @kdF I _q ꉋ݀p)F:#j.}J|`PT\m=cC3q5L}7KZp,?(z,ݧs|(~hyt=iCSxu![g3|LGNNaW8ul)Ē>S&<|w3ϩq:IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/switch_inner_insensitive.png000066400000000000000000000010111325435343100273740ustar00rootroot00000000000000PNG  IHDR: DssRGBIDATX cdMY1G3 66VVu߀ ~b4Xhf2`%D^)1hv /b& 4Vŭ8OPOFAB@* 2,WZ1 zVJ~I'ayVơ&Mur(FPݣ[z[H*GªQ^*@2(h{m~/_) Jģ w=%n9ӯANBT1Փ,bydշ>WГ__>f(U!$b$\0b4"IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/switch_inner_insensitive@2x.png000066400000000000000000000017001325435343100277530ustar00rootroot00000000000000PNG  IHDRt$XsRGBzIDATx[KkQd8ii>lSAWэ ?nܻ] HEV5T4NNwB@G̜#!{=_}{Rn|V*<_

PTD9{g@i-O)S{,Pߪņ:5vT'O>stPwpua$B=5saRmsl Q" dDۺ^Fjp۞XF(eg zj\Pőb~dwNE}`/OeAC`/hXSentr.r:@`_e/iP\`/hT5|q{AW SݔnIӶ.{AE+ՄsMeDNŴIwi?C)?3"xs{[0:M]6-zC޿F!DZR]H%OVkaIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/tick_hover.png000066400000000000000000000005501325435343100244240ustar00rootroot00000000000000PNG  IHDRH- pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?Y @ ĭvJ [xV~ ;~c oذfŰc=/Y@2l@*AA(*0p PhDu 3 <@q E_@Q5 xd 9tß_|| uLzȈP4'P&{ "$8l-#ilK/ xIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/tick_insensitive.png000066400000000000000000000005451325435343100256450ustar00rootroot00000000000000PNG  IHDRH- pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?9Xl@J |" Fi/^0jh-A@#GLkj: 6Cm[330ȏ X/2D_JH5%`#FlF3<ySotIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/tick_normal.png000066400000000000000000000006021325435343100245670ustar00rootroot00000000000000PNG  IHDRH- pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?Y @ III$((h%- c!Ujjj1M̜ZZZ@L 5Ŭ|||@6]nnngAҐ ** T*% kR3}d޽ @S_...EPC‶=߿o۶﯁9(> HA?:rKK4K [ 0q $`)KU5|-B>IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/tick_transparent.png000066400000000000000000000002031325435343100256350ustar00rootroot00000000000000PNG  IHDRH-bKGD pHYs  tIME : ~IDAT(c```8IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/transparent_button_left_hover.png000066400000000000000000000022731325435343100304440ustar00rootroot00000000000000PNG  IHDRtEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp S.IDATxtR=k@Y AC4)H*]?RZٜ Ȯnf;d1ޛ7(}"K"8 맾wM_M$0  An.IDATxtQNPwI\Il016*K+> K6  +,$' \.gǺA "a<CUUOxu]-n_ApEʲm۾:/(PuGb0nL39XZn7Ԡ|6(}9$ہp8 3,,X.`i]yC糭6$V+q(|t8DQ8X@m4n, 5Oi(\".I`81/gjIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/transparent_button_left_press.png000066400000000000000000000021471325435343100304550ustar00rootroot00000000000000PNG  IHDRtEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp rzIDATxڔ0Eyd6 ,NnN?އ5D\GPZkhЂ SY$IVXBl+<2 & vzlrIDATxT Ejq.`ݠk Q r<`IDATxDN C! 4<)PjYMS@h()xlt|VC7us眸=fJߒsyR Zkm (D)ewv1FaZ?1^%`O<ԻIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/transparent_button_middle_press.png000066400000000000000000000017021325435343100307550ustar00rootroot00000000000000PNG  IHDRMtEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp ^5IDATxbd``Hbgg #{E/Cy"+c903$ IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/transparent_button_right_hover.png000066400000000000000000000023111325435343100306200ustar00rootroot00000000000000PNG  IHDRtEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp w: N 8IDATxlQj@]TH Ez+-=ijޚ?{o{E^EVf -d7μ78B xP_VO("a^;dfFܶ '!s&MѰ4 8,ˤ@LBDZ|Qa)N< qhmۊeYB:$ʲ2:y!&4MA?n';.(TPoq)OwYP@^6A'xgb-.0 g.Di>cZU"E|R_IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/transparent_button_right_press.png000066400000000000000000000022111325435343100306300ustar00rootroot00000000000000PNG  IHDRtEXtSoftwareAdobe ImageReadyqe<#iTXtXML:com.adobe.xmp GIDATxlR;n0[ [܁" X -RPHyZ"?i@~yc0og47u9,'/pyUUYk?a ۶qQ8?뺪}YdCC+(]GS}VQQE$ `BU`T v4M@H)]4;20UQVP(˒u-i銳m%ܶ<Ϗ ^(ށW~pOxQIENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/up_hover.png000066400000000000000000000011551325435343100241200ustar00rootroot00000000000000PNG  IHDRĴl;sRGB'IDAT8!Q%!x" J@(1 7#( Ua{UˮktsK$p8~`fxtIr9;Lb- ֶ-f3uݏh4^(RtڞNt:p[xo760f45L-S |NfHZ,|~ E L(VkMsi&1)?^11'G!K3lJc<"< IfIV>z=q*uPiO*6uT*<5 ᒫk -$m4TVi𦈇!w݀՟N'e`ZFPe28u;K*@EFXkCkȳ:K's!C$q0cv CֳL ֹ|*Yh%H'p8  J_qic"N\y@fjz9bCCЍؑ'-d:_Ǵ߶W! 5)|ױ8 }ec-A]UlŁG]._~mݙ|>#ra\Tӕ:!,4GE18qd,Z (R`^b7 hw}{8pq. M2ms9 ;oeyxlLp!bHWDz/Mɹ< H #J«F/&TK#5*wr=<ާReC 9v }4C 29$稀h4z|(Xl\b2_$Uj6ǣ tGU'G3斿cR"4˲$ CnѻOW!lV:ŤMӬj 1> Al i^M|c}Dz=kC:Wz}֙6^]Lo}04IENDB`dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/000077500000000000000000000000001325435343100230705ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/close_disabled.svg000066400000000000000000000024361325435343100265520ustar00rootroot00000000000000 close-disabled-dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/close_hover.svg000066400000000000000000000026151325435343100261250ustar00rootroot00000000000000 close_hover_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/close_normal.svg000066400000000000000000000025001325435343100262630ustar00rootroot00000000000000 close_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/close_press.svg000066400000000000000000000026151325435343100261360ustar00rootroot00000000000000 close_press_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/maximize_disabled.svg000066400000000000000000000020031325435343100272560ustar00rootroot00000000000000 maximize-disabled-dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/maximize_hover.svg000066400000000000000000000021611325435343100266370ustar00rootroot00000000000000 maximize_hover_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/maximize_normal.svg000066400000000000000000000020451325435343100270050ustar00rootroot00000000000000 maximize_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/maximize_press.svg000066400000000000000000000021621325435343100266510ustar00rootroot00000000000000 maximize_active_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/menu_disabled.svg000066400000000000000000000023541325435343100264100ustar00rootroot00000000000000 menu_disabled_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/menu_hover.svg000066400000000000000000000024031325435343100257570ustar00rootroot00000000000000 menu_hover_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/menu_normal.svg000066400000000000000000000024331325435343100261270ustar00rootroot00000000000000 menu_normal_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/menu_press.svg000066400000000000000000000024021325435343100257670ustar00rootroot00000000000000 menu_press_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/minimise_disabled.svg000066400000000000000000000017111325435343100272520ustar00rootroot00000000000000 minimize-disabled-dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/minimise_hover.svg000066400000000000000000000020671325435343100266330ustar00rootroot00000000000000 minimize_hover_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/minimise_normal.svg000066400000000000000000000017531325435343100270010ustar00rootroot00000000000000 minimize_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/minimise_press.svg000066400000000000000000000020701325435343100266360ustar00rootroot00000000000000 minimize_active_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/quit_fullscreen_hover.svg000077500000000000000000000023671325435343100302330ustar00rootroot00000000000000 quit_fullscreen_dark_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/quit_fullscreen_normal.svg000077500000000000000000000022031325435343100303650ustar00rootroot00000000000000 quit_fullscreen_dark_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/quit_fullscreen_press.svg000077500000000000000000000025621325435343100302410ustar00rootroot00000000000000 quit_fullscreen_dark_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/unmaximize_disabled.svg000066400000000000000000000020531325435343100276260ustar00rootroot00000000000000 unmaximize-disabled-dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/unmaximize_hover.svg000066400000000000000000000022221325435343100272000ustar00rootroot00000000000000 unmaximize_hover_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/unmaximize_normal.svg000066400000000000000000000021241325435343100273460ustar00rootroot00000000000000 unmaximize_normal_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dark/images/window/unmaximize_press.svg000066400000000000000000000022211325435343100272100ustar00rootroot00000000000000 unmaximize_press_dark Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/dui_theme_dark.qrc000066400000000000000000000310401325435343100230440ustar00rootroot00000000000000 dark/images/window/close_disabled.svg dark/images/window/close_hover.svg dark/images/window/close_normal.svg dark/images/window/close_press.svg dark/images/window/maximize_disabled.svg dark/images/window/maximize_hover.svg dark/images/window/maximize_normal.svg dark/images/window/maximize_press.svg dark/images/window/menu_disabled.svg dark/images/window/menu_hover.svg dark/images/window/menu_normal.svg dark/images/window/menu_press.svg dark/images/window/minimise_disabled.svg dark/images/window/minimise_hover.svg dark/images/window/minimise_normal.svg dark/images/window/minimise_press.svg dark/images/window/unmaximize_disabled.svg dark/images/window/unmaximize_hover.svg dark/images/window/unmaximize_normal.svg dark/images/window/unmaximize_press.svg dark/Dtk--Widget--DWindowRestoreButton.theme dark/Dtk--Widget--DWindowOptionButton.theme dark/Dtk--Widget--DWindowMinButton.theme dark/Dtk--Widget--DWindowMaxButton.theme dark/Dtk--Widget--DWindowCloseButton.theme dark/Dtk--Widget--DToast.theme dark/Dtk--Widget--DTitlebar.theme dark/Dtk--Widget--DTextEdit.theme dark/Dtk--Widget--DTextButton.theme dark/Dtk--Widget--DSwitchButton.theme dark/Dtk--Widget--DStackWidget.theme dark/Dtk--Widget--DSpinBox.theme dark/Dtk--Widget--DSlider.theme dark/Dtk--Widget--DShortcutEdit.theme dark/Dtk--Widget--DSettingsDialog.theme dark/Dtk--Widget--DSeparatorVertical.theme dark/Dtk--Widget--DSeparatorHorizontal.theme dark/Dtk--Widget--DSegmentedControl.theme dark/Dtk--Widget--DSearchEdit.theme dark/Dtk--Widget--DScrollBar.theme dark/Dtk--Widget--DScrollArea.theme dark/Dtk--Widget--DPasswordEdit.theme dark/Dtk--Widget--DOptionList.theme dark/Dtk--Widget--DOption.theme dark/Dtk--Widget--DLoadingIndicator.theme dark/Dtk--Widget--DListView.theme dark/Dtk--Widget--DLinkButton.theme dark/Dtk--Widget--DLineEdit.theme dark/Dtk--Widget--DLabel.theme dark/Dtk--Widget--DIpv4LineEdit.theme dark/Dtk--Widget--DImageButton.theme dark/Dtk--Widget--DHeaderLine.theme dark/Dtk--Widget--DFileChooserEdit.theme dark/Dtk--Widget--DDialog.theme dark/Dtk--Widget--DComboBox.theme dark/Dtk--Widget--DCircleProgress.theme dark/Dtk--Widget--DButtonList.theme dark/Dtk--Widget--DBoxWidget.theme dark/Dtk--Widget--DBaseLine.theme dark/Dtk--Widget--DBaseExpand.theme dark/Dtk--Widget--DBaseButton.theme dark/Dtk--Widget--DArrowButton.theme dark/Dtk--Widget--DAbstractDialog.theme dark/Dtk--Widget--DAboutDialog.theme dark/images/add_hover.png dark/images/add_normal.png dark/images/add_press.png dark/images/arrow_down_hover.png dark/images/arrow_down_normal.png dark/images/arrow_down_press.png dark/images/arrow_down_white.png dark/images/arrow_down_hover.svg dark/images/arrow_down_normal.svg dark/images/arrow_down_press.svg dark/images/arrow_down_insensitive.svg dark/images/arrow_left_hover.png dark/images/arrow_left_normal.png dark/images/arrow_left_press.png dark/images/arrow_left_white.png dark/images/arrow_right_hover.png dark/images/arrow_right_normal.png dark/images/arrow_right_press.png dark/images/arrow_right_white.png dark/images/arrow_up_hover.png dark/images/arrow_up_normal.png dark/images/arrow_up_press.png dark/images/arrow_up_white.png dark/images/arrow_up_hover.svg dark/images/arrow_up_normal.svg dark/images/arrow_up_press.svg dark/images/arrow_up_insensitive.svg dark/images/button_center_normal.png dark/images/button_center_press.png dark/images/button_left_normal.png dark/images/button_left_press.png dark/images/button_right_normal.png dark/images/button_right_press.png dark/images/checkbox_checked_hover.png dark/images/checkbox_checked_insensitive.png dark/images/checkbox_checked.png dark/images/checkbox_unchecked_hover.png dark/images/checkbox_unchecked_insensitive.png dark/images/checkbox_unchecked.png dark/images/input_clear_hover.svg dark/images/input_clear_normal.svg dark/images/input_clear_press.svg dark/images/clear_white.png dark/images/delete_hover.png dark/images/delete_multi_hover.png dark/images/delete_multi_normal.png dark/images/delete_multi_press.png dark/images/delete_normal.png dark/images/delete_press.png dark/images/file_24.png dark/images/folder_24.png dark/images/folder_up_24.png dark/images/icon_view_hover.png dark/images/icon_view_normal.png dark/images/icon_view_press.png dark/images/list_view_hover.png dark/images/list_view_normal.png dark/images/list_view_press.png dark/images/loadfile_hover.png dark/images/loadfile_normal.png dark/images/loadfile_press.png dark/images/multiselect_active_normal.png dark/images/multiselect_inactive_hover.png dark/images/multiselect_inactive_normal.png dark/images/hide_password_hover.svg dark/images/hide_password_normal.svg dark/images/hide_password_press.svg dark/images/show_password_hover.svg dark/images/show_password_normal.svg dark/images/show_password_press.svg dark/images/radio_selected_hover.png dark/images/radio_selected_insensitive.png dark/images/radio_selected.png dark/images/radio_unselected_hover.png dark/images/radio_unselected_insensitive.png dark/images/radio_unselected.png dark/images/restore_hover.png dark/images/restore_normal.png dark/images/restore_press.png dark/images/search_hover.png dark/images/search_normal.png dark/images/search_press.png dark/images/slider_balance.png dark/images/slider_handle.svg dark/images/spinner_decrease_hover.png dark/images/spinner_decrease_normal.png dark/images/spinner_decrease_press.png dark/images/spinner_decrease.png dark/images/spinner_increase_hover.png dark/images/spinner_increase_normal.png dark/images/spinner_increase_press.png dark/images/spinner_increase.png dark/images/tick_hover.png dark/images/tick_insensitive.png dark/images/tick_normal.png dark/images/transparent_button_left_hover.png dark/images/transparent_button_left_normal.png dark/images/transparent_button_left_press.png dark/images/transparent_button_middle_hover.png dark/images/transparent_button_middle_normal.png dark/images/transparent_button_middle_press.png dark/images/transparent_button_right_hover.png dark/images/transparent_button_right_normal.png dark/images/transparent_button_right_press.png dark/images/up_hover.png dark/images/up_normal.png dark/images/up_press.png dark/images/switch_inner_insensitive.png dark/images/switch_inner.png dark/images/slider_bg.png dark/images/slider_bg_active.png dark/images/dark_button_press_bg.png dark/images/dark_button_normal_bg.png dark/images/dark_button_hover_bg.png dark/images/dock_preview_close_hover.png dark/images/dock_preview_close_normal.png dark/images/dock_preview_close_press.png dark/dialogs/images/check_focus.png dark/dialogs/images/dark_check_checked_hover.png dark/dialogs/images/dark_check_checked.png dark/dialogs/images/dark_check.png dark/dialogs/images/dark_close_small_hover.png dark/dialogs/images/dark_close_small_normal.png dark/dialogs/images/dark_close_small_press.png dark/dialogs/images/dark_minimise_small_hover.png dark/dialogs/images/dark_minimise_small_normal.png dark/dialogs/images/dark_minimise_small_press.png dark/dialogs/images/user-trash-full.png dark/images/combobox_up_arrow.png dark/images/combobox_down_arrow.png dark/images/tick_transparent.png dark/images/search.svg dark/images/switch_inner_insensitive@2x.png dark/images/switch_inner@2x.png dark/images/window/close_disabled.svg dark/images/window/close_hover.svg dark/images/window/close_normal.svg dark/images/window/close_press.svg dark/images/window/maximize_disabled.svg dark/images/window/maximize_hover.svg dark/images/window/maximize_normal.svg dark/images/window/maximize_press.svg dark/images/window/menu_disabled.svg dark/images/window/menu_hover.svg dark/images/window/menu_normal.svg dark/images/window/menu_press.svg dark/images/window/minimise_disabled.svg dark/images/window/minimise_hover.svg dark/images/window/minimise_normal.svg dark/images/window/minimise_press.svg dark/images/window/unmaximize_disabled.svg dark/images/window/unmaximize_hover.svg dark/images/window/unmaximize_normal.svg dark/images/window/unmaximize_press.svg dark/images/window/quit_fullscreen_hover.svg dark/images/window/quit_fullscreen_normal.svg dark/images/window/quit_fullscreen_press.svg dtkwidget-2.0.7.2/src/widgets/themes/dui_theme_light.qrc000066400000000000000000000213131325435343100232340ustar00rootroot00000000000000 light/Dtk--Widget--DWindowRestoreButton.theme light/Dtk--Widget--DWindowOptionButton.theme light/Dtk--Widget--DWindowMinButton.theme light/Dtk--Widget--DWindowMaxButton.theme light/Dtk--Widget--DWindowCloseButton.theme light/Dtk--Widget--DWindow.theme light/Dtk--Widget--DToast.theme light/Dtk--Widget--DTitlebar.theme light/Dtk--Widget--DTextEdit.theme light/Dtk--Widget--DTextButton.theme light/Dtk--Widget--DSwitchButton.theme light/Dtk--Widget--DStackWidget.theme light/Dtk--Widget--DSpinBox.theme light/Dtk--Widget--DSlider.theme light/Dtk--Widget--DSettingsDialog.theme light/Dtk--Widget--DSeparatorVertical.theme light/Dtk--Widget--DSeparatorHorizontal.theme light/Dtk--Widget--DSegmentedControl.theme light/Dtk--Widget--DSearchEdit.theme light/Dtk--Widget--DScrollBar.theme light/Dtk--Widget--DScrollArea.theme light/Dtk--Widget--DPasswordEdit.theme light/Dtk--Widget--DLoadingIndicator.theme light/Dtk--Widget--DLinkButton.theme light/Dtk--Widget--DLineEdit.theme light/Dtk--Widget--DLabel.theme light/Dtk--Widget--DImageButton.theme light/Dtk--Widget--DHeaderLine.theme light/Dtk--Widget--DFileChooserEdit.theme light/Dtk--Widget--DDialog.theme light/Dtk--Widget--DComboBox.theme light/Dtk--Widget--DButtonList.theme light/Dtk--Widget--DBoxWidget.theme light/Dtk--Widget--DBaseLine.theme light/Dtk--Widget--DBaseExpand.theme light/Dtk--Widget--DBaseButton.theme light/Dtk--Widget--DArrowButton.theme light/Dtk--Widget--DAbstractDialog.theme light/Dtk--Widget--DAboutDialog.theme light/images/arrow_down_hover.png light/images/arrow_down_normal.png light/images/arrow_down_press.png light/images/arrow_down_hover.svg light/images/arrow_down_normal.svg light/images/arrow_down_press.svg light/images/arrow_down_insensitive.svg light/images/arrow_left_hover.png light/images/arrow_left_normal.png light/images/arrow_left_press.png light/images/arrow_right_hover.png light/images/arrow_right_normal.png light/images/arrow_right_press.png light/images/arrow_up_hover.png light/images/arrow_up_normal.png light/images/arrow_up_press.png light/images/arrow_up_hover.svg light/images/arrow_up_normal.svg light/images/arrow_up_press.svg light/images/arrow_up_insensitive.svg light/images/checkbox_checked_hover.png light/images/checkbox_checked_insensitive.png light/images/checkbox_checked.png light/images/checkbox_unchecked_hover.png light/images/checkbox_unchecked_insensitive.png light/images/checkbox_unchecked.png light/images/input_clear_hover.svg light/images/input_clear_normal.svg light/images/input_clear_press.svg light/images/delete_multi_hover.png light/images/delete_multi_normal.png light/images/delete_multi_press.png light/images/multiselect_active_normal.png light/images/multiselect_inactive_hover.png light/images/multiselect_inactive_normal.png light/images/hide_password_hover.svg light/images/hide_password_normal.svg light/images/hide_password_press.svg light/images/show_password_hover.svg light/images/show_password_normal.svg light/images/show_password_press.svg light/images/radio_selected_hover.png light/images/radio_selected_insensitive.png light/images/radio_selected.png light/images/radio_unselected_hover.png light/images/radio_unselected_insensitive.png light/images/radio_unselected.png light/images/restore_hover.png light/images/restore_normal.png light/images/restore_press.png light/images/search_hover.png light/images/search_normal.png light/images/search_press.png light/images/spinner_decrease_hover.png light/images/spinner_decrease_normal.png light/images/spinner_decrease_press.png light/images/spinner_increase_hover.png light/images/spinner_increase_normal.png light/images/spinner_increase_press.png light/images/tick_hover.png light/images/tick_insensitive.png light/images/tick_normal.png light/images/slider_bg_active.png light/images/slider_bg.png light/images/slider_round.png light/images/slider_sharp.png light/images/button_press_bg.png light/images/button_normal_bg.png light/images/button_hover_bg.png light/dialogs/images/light_minimise_small_hover.png light/dialogs/images/light_minimise_small_press.png light/dialogs/images/light_minimise_small_normal.png light/dialogs/images/light_close_small_normal.png light/dialogs/images/light_check.png light/dialogs/images/check_focus.png light/dialogs/images/light_close_small_hover.png light/dialogs/images/light_close_small_press.png light/dialogs/images/light_check_checked.png light/dialogs/images/light_check_checked_hover.png light/dialogs/images/user-trash-full.png light/images/combobox_arrow.png light/images/combobox_arrow_active.png light/images/search.svg light/images/water_back.svg light/images/water_front.svg light/images/window/close_disabled.svg light/images/window/close_hover.svg light/images/window/close_normal.svg light/images/window/close_press.svg light/images/window/maximize_disabled.svg light/images/window/maximize_hover.svg light/images/window/maximize_normal.svg light/images/window/maximize_press.svg light/images/window/menu_disabled.svg light/images/window/menu_hover.svg light/images/window/menu_normal.svg light/images/window/menu_press.svg light/images/window/minimise_hover.svg light/images/window/minimise_normal.svg light/images/window/minimise_press.svg light/images/window/minimize_disabled.svg light/images/window/unmaximize_disabled.svg light/images/window/unmaximize_hover.svg light/images/window/unmaximize_normal.svg light/images/window/unmaximize_press.svg light/images/loadfile_hover.svg light/images/loadfile_normal.svg light/images/loadfile_press.svg light/images/window/quit_fullscreen_hover.svg light/images/window/quit_fullscreen_normal.svg light/images/window/quit_fullscreen_press.svg dtkwidget-2.0.7.2/src/widgets/themes/light/000077500000000000000000000000001325435343100205025ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DAboutDialog.theme000066400000000000000000000007251325435343100261230ustar00rootroot00000000000000QLabel#ProductNameLabel { font-size:18px; } QLabel#VersionLabel { font-size:12px; color: #666666; } QLabel#WebsiteLabel { font-size:13px; color: #004EE5; } QLabel#AcknowledgementLabel { font-size:13px; color: #004EE5; } QLabel#DescriptionLabel { font-size:11px; font-weight: normal; color:#1A1A1A; border: none; } QLabel#LicenseLabel { font-size:11px; font-weight: normal; color:#1A1A1A; border: none; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DAbstractDialog.theme000066400000000000000000000002431325435343100266070ustar00rootroot00000000000000Dtk--Widget--DAbstractDialog { qproperty-backgroundColor: white; qproperty-borderColor: rgba(0, 0, 0, 0.2); border-width: 1; border-radius: 4px; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DArrowButton.theme000066400000000000000000000031761325435343100262220ustar00rootroot00000000000000Dtk--Widget--ArrowButtonIcon { background-repeat: no-repeat; background-position: center; } QLabel#ArrowButtonIconNormal[arrowButtonDirection="0"] { background-image: url(:/images/light/images/arrow_up_normal.png); } QLabel#ArrowButtonIconNormal[arrowButtonDirection="1"] { background-image: url(:/images/light/images/arrow_down_normal.png); } QLabel#ArrowButtonIconNormal[arrowButtonDirection="2"] { background-image: url(:/images/light/images/arrow_left_normal.png); } QLabel#ArrowButtonIconNormal[arrowButtonDirection="3"] { background-image: url(:/images/light/images/arrow_right_normal.png); } QLabel#ArrowButtonIconHover[arrowButtonDirection="0"] { background-image: url(:/images/light/images/arrow_up_hover.png); } QLabel#ArrowButtonIconHover[arrowButtonDirection="1"] { background-image: url(:/images/light/images/arrow_down_hover.png); } QLabel#ArrowButtonIconHover[arrowButtonDirection="2"] { background-image: url(:/images/light/images/arrow_left_hover.png); } QLabel#ArrowButtonIconHover[arrowButtonDirection="3"] { background-image: url(:/images/light/images/arrow_right_hover.png); } QLabel#ArrowButtonIconPress[arrowButtonDirection="0"] { background-image: url(:/images/light/images/arrow_up_press.png); } QLabel#ArrowButtonIconPress[arrowButtonDirection="1"] { background-image: url(:/images/light/images/arrow_down_press.png); } QLabel#ArrowButtonIconPress[arrowButtonDirection="2"] { background-image: url(:/images/light/images/arrow_left_press.png); } QLabel#ArrowButtonIconPress[arrowButtonDirection="3"] { background-image: url(:/images/light/images/arrow_right_press.png); } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DBaseButton.theme000066400000000000000000000017411325435343100257760ustar00rootroot00000000000000Dtk--Widget--DBaseButton { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #3BC1FF, stop: 1.0 #079DFF); border-width: 1px; border-color: rgba(29, 130, 255, 0.30); border-style: solid; border-radius: 4px; font-size: 12px; color: white; } Dtk--Widget--DBaseButton:hover{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #6EC9FF, stop: 1.0 #2DA9F6); } Dtk--Widget--DBaseButton:pressed{ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #0B8CFF, stop: 1.0 #0AA1FF); } Dtk--Widget--DBaseButton:disabled { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 rgba(59,193,255,0.50), stop: 1.0 rgba(7,157,255,0.50)); } Dtk--Widget--DBaseButton:flat { border: none; /* no border for a flat push button */ } QFrame#ButtonInsideFrame { background-color: transparent; border-top-width: 1px; border-style: solid; border-radius: 3px; border-top-color: rgba(255, 255, 255, 0.1); } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DBaseExpand.theme000066400000000000000000000000751325435343100257410ustar00rootroot00000000000000Dtk--Widget--ContentLoader { background-color: #ffffff } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DBaseLine.theme000066400000000000000000000001531325435343100254060ustar00rootroot00000000000000/*Dtk--Widget--DBaseLine { background-color: #fafafa }*/ /*use default background color(transparent)*/ dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DBoxWidget.theme000066400000000000000000000000701325435343100256160ustar00rootroot00000000000000Dtk--Widget--DBoxWidget{ background: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DButtonList.theme000066400000000000000000000011421325435343100260320ustar00rootroot00000000000000Dtk--Widget--DButtonList { background-color: #ffffff; border: none; } Dtk--Widget--DButtonList QPushButton:hover{ color: black; } Dtk--Widget--DButtonList QFrame#BorderFrame{ background-color: transparent; } Dtk--Widget--DButtonList QFrame#BorderFrame[state="checked"]{ background-color: transparent; } Dtk--Widget--DButtonList QPushButton{ background-color: transparent; color: #b4b4b4; border: none; border-radius:3px; text-align: left center; padding-left: 40px; } Dtk--Widget--DButtonList QPushButton:checked{ background-color: white; color: #2CA7F8; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DComboBox.theme000066400000000000000000000102231325435343100254330ustar00rootroot00000000000000Dtk--Widget--DComboBox { border: 1px solid rgba(0,0,0,0.1); border-radius: 4px; padding: 1px 1px 1px 4px; color: black; font-size: 12px; qproperty-insensitiveTickImg: url(:/images/light/images/tick_insensitive.png); qproperty-hoverTickImg: url(:/images/light/images/tick_hover.png); qproperty-normalTickImg: url(:/images/light/images/tick_normal.png); background-color: rgba(0, 0, 0, 26);/*use as outside border*/ } Dtk--Widget--DComboBox:!editable, DComboBox::drop-down:editable { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffffff, stop: 1.0 #fdfdfd); /*combobox-popup: 0;*/ } Dtk--Widget--DComboBox:!editable:hover, DComboBox::drop-down:editable:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #84c8f8, stop: 1.0 #4db9ff); border: 1px solid #2CA7F8; } /* DComboBox gets the "on" state when the popup is open */ Dtk--Widget--DComboBox:!editable:on, DComboBox::drop-down:editable:on { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffffff, stop: 1.0 #fdfdfd); } QAbstractItemView#DComboBoxItemView { selection-background-color: #2CA7F8; background: transparent; margin: 0; font-size: 12px; } QComboBoxPrivateContainer { border: 1px solid #ccc; background-color: white; } QAbstractItemView#DComboBoxItemView::item { min-height: 24; color: black; } Dtk--Widget--DComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: center right; width: 16px; margin-right: 3; border-top-right-radius: 4px; /* same radius as the DComboBox */ border-bottom-right-radius: 4px; } Dtk--Widget--DComboBox::down-arrow { image: url(:/images/light/images/combobox_arrow.png); } Dtk--Widget--DComboBox::down-arrow:!editable:hover { image: url(:/images/light/images/combobox_arrow_active.png); } QAbstractItemView Dtk--Widget--DComboBoxItem { color: black; font-size: 12px; margin-left: 24; margin-bottom: 3; } QAbstractItemView Dtk--Widget--DComboBoxItem[hovered="true"] { color: black; } QAbstractItemView Dtk--Widget--DComboBoxItem[checked="true"] { color: black; } #DComboBoxTitleMask{ padding-left: 10px; } QFrame#DComboxInsideFrame { background-color: transparent; /* border-top-width: 1px; border-style: solid; border-radius: 3; border-top-color: rgba(255, 255, 255, 26); */ border: 1px solid; border-radius: 4px; border-top-color: rgba(255,255,255,26); border-left-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(255,255,255,26), stop: 1.0 rgba(255,255,255,5)); border-right-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(255,255,255,26), stop: 1.0 rgba(255,255,255,5)); border-bottom-color: rgba(255, 255, 255, 5); } QFrame#ComboboxPopupTopEnd { border-bottom: 1px solid #ccc; border-top-left-radius: 4; border-top-right-radius: 4; background: transparent url(:/images/light/images/combobox_up_arrow.png); background-repeat: no-repeat; background-position: center; } QFrame#ComboboxPopupBottomEnd { border-top: 1px solid #ccc; border-bottom-left-radius: 4; border-bottom-right-radius: 4; background: transparent url(:/images/light/images/combobox_down_arrow.png); background-repeat: no-repeat; background-position: center; } Dtk--Widget--DComboBox:editable{ border: 1px solid transparent; min-height: 21px; background-color: transparent; } QLineEdit { background: transparent; border-right: 1px solid rgba(0, 0, 0, 0.1); margin-right: 4px; } Dtk--Widget--DComboBox[editable="true"] QFrame#DComboxInsideFrame {/*outside frame*/ background-color: transparent; border: 1px solid #ccc; } Dtk--Widget--DComboBox[alert="true"] QFrame#DComboxInsideFrame{ border-color: #FF8F00; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DDialog.theme000066400000000000000000000042501325435343100251250ustar00rootroot00000000000000Dtk--Widget--DDialog{ qproperty-backgroundColor: white; qproperty-borderColor: rgba(0, 0, 0, 0.2); } QFrame#ButtonFrame{ border:1px solid rgba(0, 0, 0, 0.1); border-radius: 2px; } #CloseButton{ qproperty-normalPic: url(:/images/light/images/window/close_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/close_hover.svg); qproperty-pressPic: url(:/images/light/images/window/close_press.svg); } QPushButton#NormalButton{ background-color: transparent; border: 1px solid rgba(0, 0, 0, 0.1); border-radius: 2px; color: white; text-align: center; } QPushButton#NormalButton:hover{ background-color: transparent; color: rgba(0, 0, 0, 0.5); } QPushButton#NormalButton:pressed{ background-color: transparent; color: #01bdff; } QPushButton#ActionButton{ background-color: transparent; border: 1px solid rgba(0, 0, 0, 0.1); border-right: none; border-left: none; border-bottom: none; font-size: 13px; color: #303030; text-align: center; outline: none; } QPushButton#ActionButton[buttonType="1"] {/*warning*/ color: #ff5a5a; font-weight: 500; } QPushButton#ActionButton[buttonType="2"] {/*recommend*/ color: #0087ff; font-weight: 500; } QPushButton#ActionButton:hover{ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #8ccfff, stop:1 #4bb8ff); color: #ffffff; } QPushButton#ActionButton:pressed{ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #0b8cff, stop:1 #0aa1ff); color: #ffffff; } QPushButton#ConflictButton{ background-color: transparent; border:none; color: white; text-align: center; } QPushButton#ConflictButton:checked{ background-color: #ff9327; } QLabel#VLine{ background-color:rgba(0, 0, 0, 0.1); } QLabel#TitleLabel{ padding-top: 2px; padding-bottom: 2px; color: #000000; } QLabel#MessageLabel{ padding-top: 2px; padding-bottom: 2px; color: #444444; } QLabel#TaskTitleLabel{ padding-top: 2px; padding-bottom: 2px; font-size: 10px; color: #b4b4b4; } QListWidget{ background-color: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DFileChooserEdit.theme000066400000000000000000000003711325435343100267360ustar00rootroot00000000000000Dtk--Widget--DFileChooserEdit { qproperty-normalIcon:url(:/images/light/images/loadfile_normal.svg); qproperty-hoverIcon:url(:/images/light/images/loadfile_hover.svg); qproperty-pressIcon:url(:/images/light/images/loadfile_press.svg); } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DHeaderLine.theme000066400000000000000000000001031325435343100257170ustar00rootroot00000000000000QLabel#DHeaderLineTitle { color: #474747; font-size: 12px }dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DImageButton.theme000066400000000000000000000001261325435343100261420ustar00rootroot00000000000000Dtk--Widget--DImageButton:disabled { border: none; background: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DLabel.theme000066400000000000000000000000751325435343100247460ustar00rootroot00000000000000Dtk--Widget--DLabel { color: #474747; font-size: 12px; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DLineEdit.theme000066400000000000000000000017231325435343100254250ustar00rootroot00000000000000Dtk--Widget--DLineEdit { color: black; border-radius: 3; margin-left: 3px; background-color: rgba(255, 255, 255, 26);/*use as outside border*/ } Dtk--Widget--DLineEdit[alert="true"] QFrame#LineEditInsideFrame{ border-color: #FF8F00; } QFrame#LineEditInsideFrame {/*outside frame*/ background-color: rgba(255, 255, 255, 20%); border: 1px solid; border-radius: 3; border-color: rgba(0, 0, 0, 20%); } Dtk--Widget--DLineEdit #IconButton { border: 0px solid; border-left: 1px solid rgba(0, 0, 0, 20%); margin: 1px 0px 2px 0px; } Dtk--Widget--DLineEdit[alert="true"] #IconButton{ border-color: #FF8F00; } Dtk--Widget--DLineEdit #ClearButton { qproperty-normalPic: ":/images/light/images/input_clear_normal.svg"; qproperty-hoverPic: ":/images/light/images/input_clear_hover.svg"; qproperty-pressPic: "/images/light/images/input_clear_press.svg"; margin-right: 4px; } #AlertTooltip QLabel { color: #FF8F00; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DLinkButton.theme000066400000000000000000000003231325435343100260140ustar00rootroot00000000000000Dtk--Widget--DLinkButton { background-color:transparent; border:none; color:#0082fa; } Dtk--Widget--DLinkButton:hover { color:#01BDFF; } Dtk--Widget--DLinkButton:pressed { color:#0082fa; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DLoadingIndicator.theme000066400000000000000000000000641325435343100271370ustar00rootroot00000000000000Dtk--Widget--DLoadingIndicator { border: 0px; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DPasswordEdit.theme000066400000000000000000000023401325435343100263340ustar00rootroot00000000000000Dtk--Widget--DPasswordEdit { } Dtk--Widget--DPasswordEdit[isEchoMode="false"] #IconButton { border-radius: 2px; border-top-left-radius: 0px; border-bottom-left-radius: 0px; qproperty-normalPic:url(:/images/light/images/show_password_normal.svg); qproperty-hoverPic:url(:/images/light/images/show_password_hover.svg); qproperty-pressPic:url(:/images/light/images/show_password_press.svg); } Dtk--Widget--DPasswordEdit[isEchoMode="true"] Dtk--Widget--DImageButton { border-radius: 2px; border-top-left-radius: 0px; border-bottom-left-radius: 0px; qproperty-normalPic:url(:/images/light/images/hide_password_normal.svg); qproperty-hoverPic:url(:/images/light/images/hide_password_hover.svg); qproperty-pressPic:url(:/images/light/images/hide_password_press.svg); } Dtk--Widget--DPasswordEdit #IconButton[state="hover"] { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #8ccfff, stop: 1.0 #4bb8ff); } Dtk--Widget--DPasswordEdit #IconButton[state="press"] { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #0b8cff, stop: 1.0 #0aa1ff); } Dtk--Widget--DPasswordEdit[alert="true"] #IconButton{ border-color: #FF8F00; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DScrollArea.theme000066400000000000000000000001661325435343100257570ustar00rootroot00000000000000Dtk--Widget--DScrollArea{ border: none; } Dtk--Widget--DScrollArea::corner{ background-color: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DScrollBar.theme000066400000000000000000000014641325435343100256150ustar00rootroot00000000000000Dtk--Widget--DScrollBar::add-line,Dtk--Widget--DScrollBar::sub-line,Dtk--Widget--DScrollBar::add-page,Dtk--Widget--DScrollBar::sub-page{ background-color: transparent; } Dtk--Widget--DScrollBar{ max-width: 10; margin-right: 1px; background-color: transparent; } Dtk--Widget--DScrollBar::handle{ background-color: rgba(16,16,16,0.5); border-radius: 2px; margin: 4px 2px 4px 2px; } Dtk--Widget--DScrollBar::handle:vertical{ min-height: 20px; width: 8px; } Dtk--Widget--DScrollBar::handle:horizontal{ min-width: 20px; height: 8px; } Dtk--Widget--DScrollBar::handle:hover{ background-color: rgba(16,16,16,0.7); } Dtk--Widget--DScrollBar::add-line { border: none; background: none; } Dtk--Widget--DScrollBar::sub-line { border: none; background: none; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DSearchEdit.theme000066400000000000000000000016541325435343100257460ustar00rootroot00000000000000Dtk--Widget--DSearchEdit { border-radius: 4px; } Dtk--Widget--DSearchEdit #SearchIcon { background-color:transparent; margin: 2 -1 2 4 px; border-image:url(:/images/light/images/search.svg); } Dtk--Widget--DSearchEdit #ClearIcon { background-color:transparent; qproperty-normalPic:url(:/images/light/images/input_clear_normal.svg); qproperty-hoverPic:url(:/images/light/images/input_clear_hover.svg); qproperty-pressPic:url(:/images/light/images/input_clear_press.svg); } Dtk--Widget--DSearchEdit #Edit { background-color:transparent; border-radius:0px; color:#303030; padding-right:15px; padding-bottom: 3px; } Dtk--Widget--DSearchEdit QFrame#DEditInsideFrame { background-color: white; border: 1px solid; border-radius: 4px; border-color: rgba(0, 0, 0, 0.08); } Dtk--Widget--DSearchEdit #PlaceHolder { color:#303030; margin:0 0 0 3px; font-size:12px; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DSegmentedControl.theme000066400000000000000000000014301325435343100271770ustar00rootroot00000000000000Dtk--Widget--DSegmentedControl#DSegmentedControl{ border: 1px double black; border-radius: 3px; border-bottom-color: #22FFFFFF; background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #191919, stop: 0.2 #1e1e1e, stop: 1 #1e1e1e); min-height: 24px; max-height: 24px; } Dtk--Widget--DSegmentedControl Dtk--Widget--DSegmentedHighlight#Highlight{ background-color: #101010; } Dtk--Widget--DSegmentedControl QToolButton#Segmented:enabled{ color: #C0C0C0; padding-bottom: 2px; } Dtk--Widget--DSegmentedControl QToolButton#Segmented:hover{ color: white; } Dtk--Widget--DSegmentedControl QToolButton#Segmented{ background: transparent; color: #19A9F9; font-size: 12px; border: none; padding-bottom: 2px; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DSeparatorHorizontal.theme000066400000000000000000000003131325435343100277340ustar00rootroot00000000000000QWidget#DSeparatorTopRec { background-color: #19000000; min-height: 1; max-height: 1; } QWidget#DSeparatorBottomRec { background-color: #19000000; min-height: 0; max-height: 0; }dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DSeparatorVertical.theme000066400000000000000000000003071325435343100273570ustar00rootroot00000000000000QWidget#DSeparatorLeftRec { background-color: #19000000; min-width: 1; max-width: 1; } QWidget#DSeparatorRightRec { background-color: #19000000; min-width: 0; max-width: 0; }dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DSettingsDialog.theme000066400000000000000000000040451325435343100266500ustar00rootroot00000000000000#DSettingsDialog{ qproperty-backgroundColor: white; qproperty-borderColor: rgba(0, 0, 0, 0.2); } #Navigation{ border: none; border-right: 1px solid rgba(0,0,0,0.1); } #NavigationBar{ border: none; } #ButtonGroupSingle { border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 4.0px; } #ButtonGroupBegin { border: 1px solid rgba(0, 0, 0, 0.08); border-top-left-radius: 4.0px; border-bottom-left-radius: 4.0px; } #ButtonGroupBegin:checked { background-color: #2ca7f8; border: solid 1px rgba(0, 90, 224, 0.22); } #ButtonGroupMiddle { border-top: 1px solid rgba(0, 0, 0, 0.08); border-bottom: 1px solid rgba(0, 0, 0, 0.08); border-right: 1px solid rgba(0, 0, 0, 0.08); } #ButtonGroupMiddle:checked { background-color: #2ca7f8; border: solid 1px rgba(0, 90, 224, 0.22); } #ButtonGroupEnd { border: 1px solid rgba(0, 0, 0, 0.08); border-left: none; border-top-right-radius: 4.0px; border-bottom-right-radius: 4.0px; } #ButtonGroupEnd:checked { background-color: #2ca7f8; border: solid 1px rgba(0, 90, 224, 0.22); } #SettingsContentReset { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFFF, stop:1 #FBFBFB); border-color: rgba(0, 131, 255, 0.4); border-radius: 4; border-style: solid; border-width: 1; outline: none; padding: 3px 24px 4px 24px; color: #0699ff; font-size: 14px; } #SettingsContentReset:hover { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #8ccfff, stop:1 #4bb8ff); color: #FFFFFF; border-color: rgba(0, 117, 243, 0.2); } #SettingsContentReset:pressed { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #0b8cff, stop:1 #0aa1ff); color: #FFFFFF; border-color: rgba(29, 129, 255, 0.3); } #DSettingsDialogClose{ qproperty-normalPic: url(:/images/light/images/window/close_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/close_hover.svg); qproperty-pressPic: url(:/images/light/images/window/close_press.svg); } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DSlider.theme000066400000000000000000000031161325435343100251500ustar00rootroot00000000000000/*************************************For Round Handle***************************************/ Dtk--Widget--DSlider::groove[handleType="1"] { margin-left: 11px; margin-right: 11px; border-width: 0px 2px 0px 2px; height: 2px; } Dtk--Widget--DSlider::handle[handleType="1"] { background: url(:/images/light/images/slider_round.png); repeat: no-repeat; width: 22px; height: 22px; margin-top: -10px; margin-bottom: -11px; margin-left: -11px; margin-right: -11px; } Dtk--Widget--DSlider::add-page:horizontal[handleType="1"] { border-width: 0px 2px 1px 2px; border-image: url(:/images/light/images/slider_bg.png) 0 2 1 2 stretch; margin-right: 11px; height: 2px; } Dtk--Widget--DSlider::sub-page[handleType="1"] { border-width: 0px 2px 0px 2px; border-image: url(:/images/light/images/slider_bg_active.png) 0 2 0 2 stretch; margin-left: 11px; margin-bottom: -0.5px;/*Expand outside the groove */ margin-top: -0.5px;/*Expand outside the groove */ height: 2px; } /*************************************For Sharp Handle***************************************/ Dtk--Widget--DSlider::groove[handleType="0"] { margin-left: 11px; margin-right: 11px; border-width: 0px 2px 0px 2px; border-image: url(:/images/light/images/slider_bg.png) 0 2 0 2 stretch; height: 2px; } Dtk--Widget--DSlider::handle[handleType="0"] { background: url(:/images/light/images/slider_sharp.png); width: 20px; height: 22px; margin-top: -10px; margin-bottom: -10px; margin-left: -11px; margin-right: -11px; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DSpinBox.theme000066400000000000000000000016461325435343100253160ustar00rootroot00000000000000QAbstractSpinBox { min-height: 22px; color: #fff; border-radius: 3; padding-right: 53px; background-color: rgba(255, 255, 255, 26);/*use as outside border*/ } QFrame#SpinBoxInsideFrame {/*outside frame*/ background-color: rgba(0, 0, 0, 50); border: 1px solid black; border-radius: 3; } #SpinBox_ImageButton { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #50333333, stop: 1.0 #50000000); border-left: 1px solid #AA111111; } QAbstractSpinBox[alert="true"] QFrame#SpinBoxInsideFrame{ border-color: #FF8F00; } QAbstractSpinBox::up-button { border: none; background: transparent; } QAbstractSpinBox::up-arrow { border: none; background: transparent; } QAbstractSpinBox::down-button { border: none; background: transparent; } QAbstractSpinBox::down-arrow { border: none; background: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DStackWidget.theme000066400000000000000000000000721325435343100261350ustar00rootroot00000000000000Dtk--Widget--DStackWidget{ background: transparent; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DSwitchButton.theme000066400000000000000000000005531325435343100263650ustar00rootroot00000000000000Dtk--Widget--DSwitchButton#DSwitchButton{ qproperty-enabledImageSource: ":/images/dark/images/switch_inner.png"; qproperty-disabledImageSource: ":/images/dark/images/switch_inner_insensitive.png"; qproperty-animationStartValue: -20; qproperty-animationEndValue: 0; qproperty-animationDuration: 150; qproperty-animationType: InOutQuad; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DTextButton.theme000066400000000000000000000010611325435343100260430ustar00rootroot00000000000000Dtk--Widget--DTextButton { padding:0 5px; min-width:60px; color:#333; outline:none; border-width:5px 5px 5px 5px; border-image:url(:/images/light/images/button_normal_bg.png) 5 5 5 5 stretch; background-color:transparent; } Dtk--Widget--DTextButton:hover { color:#111; border-image:url(:/images/light/images/button_hover_bg.png) 5 5 5 5 stretch; } Dtk--Widget--DTextButton:pressed { border-image:url(:/images/light/images/button_press_bg.png) 5 5 5 5 stretch; } Dtk--Widget--DTextButton:checked { color:#01BDFF; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DTextEdit.theme000066400000000000000000000006111325435343100254550ustar00rootroot00000000000000Dtk--Widget--DTextEdit { color: #fff; border-radius: 3; background-color: rgba(255, 255, 255, 26);/*use as outside border*/ } Dtk--Widget--DTextEdit[alert="true"] QFrame#TextEditInsideFrame{ border-color: #FF8F00; } QFrame#TextEditInsideFrame {/*outside frame*/ background-color: rgba(0, 0, 0, 50); border: 1px solid; border-radius: 3; border-color: black; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DTitlebar.theme000066400000000000000000000014631325435343100254770ustar00rootroot00000000000000Dtk--Widget--DTitlebar { background: qlineargradient(x1:1, y1:0, x2:1, y2:1, stop:0 #ffffff, stop:1 #f8f8f8); } Dtk--Widget--DTitlebar[transparent=true] { background: transparent; } Dtk--Widget--DWindowCloseButton { qproperty-normalPic: url(:/images/light/images/window/close_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/close_hover.svg); qproperty-pressPic: url(:/images/light/images/window/close_press.svg); padding-right: 6px; } #DTitlebarDWindowQuitFullscreenButton { qproperty-normalPic: url(:/images/light/images/window/quit_fullscreen_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/quit_fullscreen_hover.svg); qproperty-pressPic: url(:/images/light/images/window/quit_fullscreen_press.svg); padding-right: 6px; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DToast.theme000066400000000000000000000001561325435343100250210ustar00rootroot00000000000000Dtk--Widget--DToast { border: 1px solid rgba(0,0,0,10%); border-radius: 4px; background: white; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DWindow.theme000066400000000000000000000004221325435343100251720ustar00rootroot00000000000000Dtk--Widget--DWindow { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #3BC1FF, stop: 1.0 #079DFF); border-width: 1px; border-color: rgba(29, 130, 255, 0.30); border-style: solid; border-radius: 3; font-size: 12px; color: white; } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DWindowCloseButton.theme000066400000000000000000000005301325435343100273540ustar00rootroot00000000000000Dtk--Widget--DWindowCloseButton { qproperty-normalPic: url(:/images/light/images/window/close_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/close_hover.svg); qproperty-pressPic: url(:/images/light/images/window/close_press.svg); qproperty-disabledPic: url(:/images/light/images/window/close_disabled.svg); } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DWindowMaxButton.theme000066400000000000000000000013621325435343100270400ustar00rootroot00000000000000Dtk--Widget--DWindowMaxButton[isMaximized=true] { qproperty-normalPic: url(:/images/light/images/window/unmaximize_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/unmaximize_hover.svg); qproperty-pressPic: url(:/images/light/images/window/unmaximize_press.svg); qproperty-disabledPic: url(:/images/light/images/window/unmaximize_disabled.svg); } Dtk--Widget--DWindowMaxButton[isMaximized=false] { qproperty-normalPic: url(:/images/light/images/window/maximize_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/maximize_hover.svg); qproperty-pressPic: url(:/images/light/images/window/maximize_press.svg); qproperty-disabledPic: url(:/images/light/images/window/maximize_disabled.svg); } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DWindowMinButton.theme000066400000000000000000000005421325435343100270350ustar00rootroot00000000000000Dtk--Widget--DWindowMinButton { qproperty-normalPic: url(:/images/light/images/window/minimise_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/minimise_hover.svg); qproperty-pressPic: url(:/images/light/images/window/minimise_press.svg); qproperty-disabledPic: url(:/images/light/images/window/minimize_disabled.svg); } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DWindowOptionButton.theme000066400000000000000000000005251325435343100275630ustar00rootroot00000000000000Dtk--Widget--DWindowOptionButton { qproperty-normalPic: url(:/images/light/images/window/menu_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/menu_hover.svg); qproperty-pressPic: url(:/images/light/images/window/menu_press.svg); qproperty-disabledPic: url(:/images/light/images/window/menu_disabled.svg); } dtkwidget-2.0.7.2/src/widgets/themes/light/Dtk--Widget--DWindowRestoreButton.theme000066400000000000000000000004301325435343100277310ustar00rootroot00000000000000Dtk--Widget--DWindowRestoreButton { qproperty-normalPic: url(:/images/light/images/window/unmaximize_normal.svg); qproperty-hoverPic: url(:/images/light/images/window/unmaximize_hover.svg); qproperty-pressPic: url(:/images/light/images/window/unmaximize_press.svg); } dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/000077500000000000000000000000001325435343100221245ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/000077500000000000000000000000001325435343100233715ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/check_focus.png000066400000000000000000000003251325435343100263530ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(cdhT^@6alϯ _gf+fb2`XXp{[lTf224|W1=L`g2D̄,F {xhE (ZfTU-??W70>XԤe?tIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/light_check.png000066400000000000000000000003071325435343100263430ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(͒1 E[/ .;p2b7kKC3ԳARJ>jW̑!2s~N9Wlg-:p`ۑ=>O l`1㭈92d :2 IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/light_check_checked.png000066400000000000000000000005171325435343100300140ustar00rootroot00000000000000PNG  IHDR Vu\sRGB IDAT(c?# 1+coZb###V eڠx.Ӂ~}l+> &LHa9 xyyY`l]]]fbb/01'L:5&Q^^hii}apSϝ;wݽlҤI>|x&KKKhA9::ے7$@6b&-гA 3Ɂ߂l )ie}saIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/light_check_checked_hover.png000066400000000000000000000006701325435343100312170ustar00rootroot00000000000000PNG  IHDR Vu\sRGBrIDAT(c````ebabb|ddžAr 5 @F]eB.n1@-@)$c^_94][ܢ@@E |j߯R2>P糽~yʠ^Rab102Xb@J{KXyY!f5010ܘQpwQ= V|l=íy5 Y`19v~ W n̬`KaP.Hu63\/:?wzj-J Lau/>޼ȠU598%+?X??°E=3M¯7sf#0(@z ' K}z|& y`I}~1IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/light_close_small_hover.png000066400000000000000000000003261325435343100307670ustar00rootroot00000000000000PNG  IHDRVsRGBIDATH R 0,}C,>}Ð%~-Krox<#1@j@)7]Ϡl^YzI" 2*c3Y3Yj aw|cIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/light_close_small_press.png000066400000000000000000000003261325435343100310000ustar00rootroot00000000000000PNG  IHDRVsRGBIDATH R;0rsvpv>,~ C[x=Rwy\k{yTt]^ 6}^w,,pPh""W)ImhD+lR#a Zw@9B$LIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/light_minimise_small_hover.png000066400000000000000000000002111325435343100314650ustar00rootroot00000000000000PNG  IHDR霝sRGBCIDATH c`!0!0B TEPD6gFo|jI,?zF5h8HLIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/light_minimise_small_normal.png000066400000000000000000000002161325435343100316370ustar00rootroot00000000000000PNG  IHDR霝sRGBHIDATH 1 @t,=@XIY[8(@v>R `f1uGVwWwا(@ a(IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/light_minimise_small_press.png000066400000000000000000000002121325435343100314770ustar00rootroot00000000000000PNG  IHDR霝sRGBDIDATH c`!0!0BNne`d"m ̽e'I2j  )~IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/dialogs/images/user-trash-full.png000066400000000000000000000036621325435343100271430ustar00rootroot00000000000000PNG  IHDR00WsBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org</IDAThmpTW}f߲ !I"fHu:% t8NGqPEbP&qDQ0qݘ}9~Hnt?sΞ{<<ϽpO-qLV9!BueYJ)E R!kR^,R^B,ˊ=@DJ1M|<?q+CCC !5o*xoDI(_͈5F͇*;5ID9Hg613@`"Dd_ ~~tj bլ"~~pu~N:nd7l66I(uﻜaWh+ u';nxXsߗ'8ݍlulWi6G*m*Kpo5R婼nl# iy[٘QӮ@i1xrB['" `z\ݏWW|o_aMʂeSŀ Sh kٙ_Rbo5g]T'sglFuA%A{!} !.Y}?^ ?w_Ŕ?.33ui/~fM984EO}{F?9&-v^›5 [4?oI }՞0oM.9L<>jYv,}b.ӺllԦhT{OTժT25+[T\KA[2mrm'̨{wZ9 mۚٹs/R^(g`չ4~6nܨK)NH$ii90%ٵd2se]d>XQJy1cuL\<ȑnjɲHd535X `1ZRN-cn'|&&,jv IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/000077500000000000000000000000001325435343100217475ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_down_hover.png000066400000000000000000000002151325435343100260370ustar00rootroot00000000000000PNG  IHDR sRGBGIDATc`;l_L< xĒP|8U db~ >U@Xe) H IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_down_hover.svg000066400000000000000000000011631325435343100260550ustar00rootroot00000000000000 down_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_down_insensitive.svg000066400000000000000000000012251325435343100272710ustar00rootroot00000000000000 down_insensitive Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_down_normal.png000066400000000000000000000002741325435343100262110ustar00rootroot00000000000000PNG  IHDR sRGBvIDATc`+`444ڸϟ? f;P\ >ŋOKKK|ccc={v3#LA%@ .4P< j7\ %9IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_down_normal.svg000066400000000000000000000011651325435343100262240ustar00rootroot00000000000000 down_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_down_press.png000066400000000000000000000003051325435343100260500ustar00rootroot00000000000000PNG  IHDR sRGBIDATc`+`]߿kXχ_n֟0gcz1ۍ)ѿXx!#Lʟ ؙ~(R${LN9Og+~ R:0ZIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_down_press.svg000066400000000000000000000011631325435343100260660ustar00rootroot00000000000000 down_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_left_hover.png000066400000000000000000000002441325435343100260240ustar00rootroot00000000000000PNG  IHDR sRGB^IDATc`؁!0)&1# SȻ ĝ(H 9g"a0E0D`&ecp" 7uaȠ o*pbxg =IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_left_normal.png000066400000000000000000000003331325435343100261700ustar00rootroot00000000000000PNG  IHDR sRGBIDATc`<== C`RL0z3P)~8P Vi&@3 ##tq:; PN s#Me0&18qPh= 8r{III /E K83IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_left_press.png000066400000000000000000000003471325435343100260410ustar00rootroot00000000000000PNG  IHDR sRGBIDATc`9 >IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_up_hover.png000066400000000000000000000002161325435343100255150ustar00rootroot00000000000000PNG  IHDR sRGBHIDATc`P0h U@s@G@ J@  < db,f *(IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_up_hover.svg000066400000000000000000000013031325435343100255260ustar00rootroot00000000000000 up_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_up_insensitive.svg000066400000000000000000000013451325435343100267510ustar00rootroot00000000000000 up_insensitive Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_up_normal.png000066400000000000000000000002611325435343100256620ustar00rootroot00000000000000PNG  IHDR sRGBkIDATc`8```0Av o 僥Ӏ Ϟ=OT18wpk`@@h!P4ɱV6IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_up_normal.svg000066400000000000000000000013051325435343100256750ustar00rootroot00000000000000 up_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/arrow_up_press.png000066400000000000000000000002721325435343100255300ustar00rootroot00000000000000PNG  IHDR sRGBtIDATc`8 up_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/button_hover_bg.png000066400000000000000000000012061325435343100256420ustar00rootroot00000000000000PNG  IHDR连sRGB@IDAT8U=OTA- X!TFbbGj(m $Hb&XXh Q!>gff N~3g̾g^|.- Fˋd{R:Nf0ֳ\fLDk4k6p qUۣB~Y}w]lNezFRGA'4BbpfJzY"OS_Tjm8sT@2ESK"Fb$Bab&ʎݕAZbOHRZMwĄ" MzLbPɚc (TU=ەβZ^})OzKf;ׯ8\>6X_ƄF]9̿ղR87S7YyJA3~!>0wYIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/button_normal_bg.png000066400000000000000000000006511325435343100260120ustar00rootroot00000000000000PNG  IHDR连sRGBcIDAT81o@ ;e\{L҉Hu|;B(;S {{~8u]wq}hf},_8Y3k]\tB(GL\e E!,ѢTtg\;@!T4p N` 'i#! 7;o!oGD;Yxj-El/Ix]= P^̪<~Br YQE4y4F @Mm5s X7y&(4Mx$uCr u͎p\U۶2l",K,k,@ZPp]-MӐom4}Zmks1$KIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/checkbox_checked_hover.png000066400000000000000000000007701325435343100271200ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(mR=hSQ{PZpMqDJUdrPEKlDJ!:5CR Q38CACy\.oU /7}$\1NPs-3wC (z~H5| ێ2 d0d heA`͟cDG6?'%$`-|ni81`_Z[x\$JP.̣RzͶt*eaf.** ++_t<ΝGeoc}.` tg4PXLeo '!~ :B^NO_ QLh@o`1خCx~IzP3 R(Bq gYCC$OcHUi(#+3yx2-+IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/checkbox_checked_insensitive.png000066400000000000000000000004721325435343100303340ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(cd LP>:( 0 uɹqu׮]4}b M<<M 9ZP )i:iU$IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/checkbox_unchecked_hover.png000066400000000000000000000003201325435343100274520ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(c?W>of,,?Q1fg%_r?3l$C>|e9ցԀ2! @ gB O,@jIMZnNIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/checkbox_unchecked_insensitive.png000066400000000000000000000003101325435343100306660ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(cd LP>:( 0 uɹqu׮]4}b M<<Gs8St&C~(^iЦ3g,XddytkGwG>Q$N&rb>$LG;({2!*?َ0j#X4/ށlXcAM\.~jkn ܂jސMU_񻠧L! ig/Kp0AXrNuHĉH8?65l6Qx[ړ?UB9#ߏ[}Οt%YIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/delete_multi_normal.png000066400000000000000000000006711325435343100265050ustar00rootroot00000000000000PNG  IHDRasRGBsIDAT8c`@wi/?0Ab@94 0 30pyiQy]' wN]a8Β1+HlX#_V003d```ypp^b`e/g!u͈ft@.FP0Ǧ ~badX.!^&*Ida<;  ӔJ@L /^'!TP/Ë{bH-(UR L Ja\%e 73R3r)#IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/delete_multi_press.png000066400000000000000000000006601325435343100263470ustar00rootroot00000000000000PNG  IHDRasRGBjIDAT8c`@?,u??Ab 94 0܂Yt~,Y!eeX8bb>w'-%JK$4xy=зF/_E߽ٶMd؀]bg4?~\fc-$dçpF\6r ʕY׍~̙/#%ES6(H = ,L""l>C̝; _j;>>p 2aUI ˿7o~[`6@zݿHH = A) 5Z^8Ai hide_password_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/hide_password_normal.svg000066400000000000000000000020251325435343100266720ustar00rootroot00000000000000 hide_password_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/hide_password_press.svg000066400000000000000000000020241325435343100265350ustar00rootroot00000000000000 hide_password_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/input_clear_hover.svg000066400000000000000000000026511325435343100262040ustar00rootroot00000000000000 input_clear_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/input_clear_normal.svg000066400000000000000000000026151325435343100263510ustar00rootroot00000000000000 input_clear_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/input_clear_press.svg000066400000000000000000000026261325435343100262170ustar00rootroot00000000000000 input_clear_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/loadfile_hover.svg000066400000000000000000000024331325435343100254540ustar00rootroot00000000000000 select-hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/loadfile_normal.svg000066400000000000000000000023541325435343100256230ustar00rootroot00000000000000 select-normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/loadfile_press.svg000066400000000000000000000024361325435343100254700ustar00rootroot00000000000000 select-press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/multiselect_active_normal.png000066400000000000000000000010221325435343100277050ustar00rootroot00000000000000PNG  IHDRasRGBIDAT8c`@n/{_?Ab 94 0Vͅuf[θ_mҕ"|{ʅ,KK$4 J ?*aWBq6L?(>K/&ez5tQt9 = L ڠ#sBݷ{ l`AT& = Lڌ号~Yb)>PeUP"!2@Q@~atR KqB"(m'(!ȩ$RR r}g0UKʷZ3S/ _|g`ebePU`clXקW=ݫLc 5;b?IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/multiselect_inactive_hover.png000066400000000000000000000007401325435343100300750ustar00rootroot00000000000000PNG  IHDRasRGBIDAT8SNPRE'6'WCtID$"OйO!%8+2 04)ti/HkHs$}sBNl>.JwbnqϗxX<8IѲC7={T*><sj"?$#K$IqqOm&r5I#VNFLi)ȁJcj BNp f'޺$c "Se²: w9 iHe]؅ r|t\ ]oU`NѤ)0Kf;amd0m'I<$%%$rqCTFۚU9(:MD ~%}],YsګIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/multiselect_inactive_normal.png000066400000000000000000000007541325435343100302470ustar00rootroot00000000000000PNG  IHDRasRGBIDAT8SNPh tr5Dd#a5 .|.$4 ,: qu` `iRiZҀUoҾw=OX^?KRx<FO6Ms^V}!h4J,kkIdDZgٳawjbLGL&sfsa۶ʏs1'H !? g BFF:΋Ͳ(_Ib͚?<H,x|.p4X,1c:C wd;%E9_1?mvp($eM=$\tb*#(e8 CTX,k]`n21)O/ s!U"Z4On۬;[& D~L[(m >g1۫0IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/radio_selected.png000066400000000000000000000003721325435343100254250ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(1 'hw&ΜƓ0y!ǦG $:to4>3jL?+ 4]νܙ-, L/trI4MO4݁C `m[uݣO}CES(:me8VUű$ɍ*u͂  5V¾B8ٶ͚<0{uiABߕ82 |YxV0 XC,9uݝiu]?ax!4/4߂sh5,IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/radio_unselected.png000066400000000000000000000003601325435343100257650ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(cd@@.sAP Pl@J!;~ AlHAj@СC /H $AUaS jȹ F a2hZ& %**҉@p4@~!]P5@ϝ;wG?PI At1B,%ďIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/radio_unselected_hover.png000066400000000000000000000007361325435343100271770ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(MR=OA}(V8(J$*(4QF "R%Ei*h(awQw7{DHy7(ggq<^F)8ʣy%<+S6f[U6j J,Fu &YZ/vrˆSR`cX(rk*٪fqV2ett͏ pta ԉ~b>1xLE =r 6BA$(&/ ,F?4X:Hir9(&u|iȁb&,-5hYÚ[p-!#swk$R-ߑNW}tUÔNaTV,k?:4;TuK.Y\m5G([鼎r5[?;\"IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/radio_unselected_insensitive.png000066400000000000000000000004601325435343100304060ustar00rootroot00000000000000PNG  IHDR Vu\sRGBIDAT(cd@\@.@oP bJ0iᆆǏAlHAjA9rDZE%=z6P-HX3Te8##| ZJ0YO@VV,bbbBJPEjX`FiիwxԀj4|;w=Bj%)XA~͛7(TTT988X//=a*[[;IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/restore_hover.png000066400000000000000000000005701325435343100253450ustar00rootroot00000000000000PNG  IHDRĴl;sRGB2IDAT8c`3M6;\@lo.5I"ZQQBbX z##+kmCCt50>L- ?߿ 0 gw Ђ\\\@ևbkw ?Z^^^ Zʂ@|.I @|tt}(rss(www_okkfNcS,/06# 'Of23 +dbccSf4X0i\ t++z`#O"^8!YDi\mIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/restore_normal.png000066400000000000000000000005311325435343100255070ustar00rootroot00000000000000PNG  IHDRĴl;sRGBIDAT8c`3Mx39c d(Pn˿p'ΈMÇoŦ.w122k?- X vppjG:TS rj@4 ;h9Hp&VAx k-0:x`4$ &En@(PׯLWvl#: blŴـ|'OG6XTT h;wL ȊT8p@Cab`x \ĬǕPl zi_IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/restore_press.png000066400000000000000000000003361325435343100253560ustar00rootroot00000000000000PNG  IHDRĴl;sRGBIDAT8c`6L>Lm߁ } 4& cbׁx2 1d5 p3XJ ǡ (qS$ oPPu1(2e@' #:Ub7-끘K<IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/search.svg000066400000000000000000000022071325435343100237360ustar00rootroot00000000000000 search Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/search_hover.png000066400000000000000000000010051325435343100251210ustar00rootroot00000000000000PNG  IHDRasBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDAT8kAofpR V6bqkwݒ\!66)KSrIBl^,n/l;_7{oFTkB&W"l?Tl6{?^"A$ey1pq!vG,x<<Lb(z 7Z{) "Ƙ=`F'"-iyn{6(:@r wk:@G N7k1 ;˲BpYjZ{ܬ]~4MHs_ʲ#KU +4};̷S/&Xdr5>1뚚Oy[:m~QIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/search_normal.png000066400000000000000000000010201325435343100252630ustar00rootroot00000000000000PNG  IHDRasBIT|d pHYs B(xtEXtSoftwarewww.inkscape.org<IDAT8kAƿofHHo@? U۽2666V-REBk+}^C1͏}CUu/Ԅ dtkwidget-2.0.7.2/src/widgets/themes/light/images/show_password_normal.svg000066400000000000000000000025631325435343100267500ustar00rootroot00000000000000 show_password_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/show_password_press.svg000066400000000000000000000025621325435343100266130ustar00rootroot00000000000000 show_password_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/slider_bg.png000066400000000000000000000001651325435343100244110ustar00rootroot00000000000000PNG  IHDR8sRGB/IDATH c>}V/ !0#0?i{ˣ!0h!ZIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/slider_bg_active.png000066400000000000000000000001521325435343100257400ustar00rootroot00000000000000PNG  IHDR{qosRGB$IDAT8cYc+#(!aQ#f/IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/slider_round.png000066400000000000000000000013001325435343100251400ustar00rootroot00000000000000PNG  IHDRĴl;sRGBzIDAT8jZQ5I1`}Jn+y|qBI6] Y v~376ts|sn$rE CWZi=z>ń^L&?V\.=regB4A\>Āx<+g|t:}@H \zD8OD d;3 *([Fw 0/R\K6E6;N=Z, jZ VΕ|f?[u4Fl>n{K4v.<2Ln߈N)o67pл3ͷVXH,`0tzjpX ִVEHЇ }msǵ-$B[T*U"*˲1 )(:vUIk?_e{x|P(l4\#|x0#5.lw56tiE~u(HbLڵ+^p桲w1NMD۶Yay@5GCxK[Ondt]UYMn;Յi7/cT*Tt*Z#ʜ(9h4 I$n>8tee8ߝ ^=Kbŋ2(aЙl6(Cr޹z>P!)exDm,eIj {v. \NR`y_FRy7F>w:Rs(.pUmj/ܫqАrt1&_~/7&w-oP(rIW/&gT} ,;;KL,|KW0TTE10B1x7~T))pSOL 0UD_wIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/switch_inner_insensitive.png000066400000000000000000000013321325435343100275700ustar00rootroot00000000000000PNG  IHDR: DssRGBIDATX ՗kA&]SP__2-k jRIǶ^o_#4D"I4glcޛDžWvUUUJQh4Tʝ̠ⓒN~1] OZ(˫j3Xͣ$(V.+T*y0i1Җ kYhCeWbX!_LOgz>*b18ȭ*( BX= DBp=Ǡ! LE` ͫgh8k?FE'tֶ~D?(ef/̠hN~dg;wJ IA%nvTttfglRtV-&V9…w6~ZoyA^#*IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/tick_hover.png000066400000000000000000000003551325435343100246150ustar00rootroot00000000000000PNG  IHDRH- pHYs  tEXtSoftwareAdobe ImageReadyqe<zIDATxb?9?F"HMF, 4đJ&*@dLN@tנ;k §]3iDּWHK @`@ 0^B(IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/tick_insensitive.png000066400000000000000000000004151325435343100260270ustar00rootroot00000000000000PNG  IHDRH- pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?9\L({'Hb55~(wF,``@ @=^ė0gxJ4Ckt@Cl>YH aNha @E g&BETʁ0``NPʮeIENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/tick_normal.png000066400000000000000000000004331325435343100247570ustar00rootroot00000000000000PNG  IHDRH- pHYs  tEXtSoftwareAdobe ImageReadyqe<IDATxb?9LB…  ) zf HC04BHC@g^@TpH hmr75M|$ C N@v #r<5l@!̉X5b t3bK9H5%` jFlx @i %i>@IENDB`dtkwidget-2.0.7.2/src/widgets/themes/light/images/water_back.svg000066400000000000000000000052771325435343100246050ustar00rootroot00000000000000 image/svg+xml water_back Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/water_front.svg000066400000000000000000000051601325435343100250240ustar00rootroot00000000000000 image/svg+xml water_front Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/000077500000000000000000000000001325435343100232565ustar00rootroot00000000000000dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/close_disabled.svg000066400000000000000000000024371325435343100267410ustar00rootroot00000000000000 close_disabled Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/close_hover.svg000066400000000000000000000026741325435343100263200ustar00rootroot00000000000000 close_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/close_normal.svg000066400000000000000000000024211325435343100264530ustar00rootroot00000000000000 close_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/close_press.svg000066400000000000000000000026741325435343100263310ustar00rootroot00000000000000 close_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/maximize_disabled.svg000066400000000000000000000020041325435343100274450ustar00rootroot00000000000000 maximize_disabled Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/maximize_hover.svg000066400000000000000000000021541325435343100270270ustar00rootroot00000000000000 maximize_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/maximize_normal.svg000066400000000000000000000017331325435343100271760ustar00rootroot00000000000000 maximize_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/maximize_press.svg000066400000000000000000000021541325435343100270400ustar00rootroot00000000000000 maximize_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/menu_disabled.svg000066400000000000000000000023511325435343100265730ustar00rootroot00000000000000 menu_disabled Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/menu_hover.svg000066400000000000000000000024531325435343100261520ustar00rootroot00000000000000 menu_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/menu_normal.svg000066400000000000000000000024771325435343100263250ustar00rootroot00000000000000 menu_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/menu_press.svg000066400000000000000000000024531325435343100261630ustar00rootroot00000000000000 menu_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/minimise_hover.svg000066400000000000000000000021321325435343100270120ustar00rootroot00000000000000 minimise_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/minimise_normal.svg000066400000000000000000000017121325435343100271620ustar00rootroot00000000000000 minimise_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/minimise_press.svg000066400000000000000000000021321325435343100270230ustar00rootroot00000000000000 minimise_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/minimize_disabled.svg000066400000000000000000000017121325435343100274500ustar00rootroot00000000000000 minimize_disabled Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/quit_fullscreen_hover.svg000077500000000000000000000023701325435343100304130ustar00rootroot00000000000000 quit_fullscreen_light_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/quit_fullscreen_normal.svg000077500000000000000000000021741325435343100305620ustar00rootroot00000000000000 quit_fullscreen_light_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/quit_fullscreen_press.svg000077500000000000000000000023701325435343100304240ustar00rootroot00000000000000 quit_fullscreen_light_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/unmaximize_disabled.svg000066400000000000000000000020451325435343100300150ustar00rootroot00000000000000 unmaximize_disabled Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/unmaximize_hover.svg000066400000000000000000000022151325435343100273700ustar00rootroot00000000000000 unmaximize_hover Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/unmaximize_normal.svg000066400000000000000000000017721325435343100275440ustar00rootroot00000000000000 unmaximize_normal Created with Sketch. dtkwidget-2.0.7.2/src/widgets/themes/light/images/window/unmaximize_press.svg000066400000000000000000000022151325435343100274010ustar00rootroot00000000000000 unmaximize_press Created with Sketch. dtkwidget-2.0.7.2/src/widgets/widgets.pri000066400000000000000000000141421325435343100202720ustar00rootroot00000000000000include(private/private.pri) include(dialogs.pri) include($$PWD/../platforms/platforms.pri) linux { include(startupnotifications/startupnotifications.pri) INCLUDEPATH += $$PWD/../platforms/linux } win32* { INCLUDEPATH += $$PWD/../platforms/windows } linux{ HEADERS += \ $$PWD/dmpriscontrol.h SOURCES += \ $$PWD/dmpriscontrol.cpp } mac{ HEADERS +=\ $$PWD/../platforms/mac/osxwindow.h OBJECTIVE_SOURCES += \ $$PWD/../platforms/mac/osxwindow.mm INCLUDEPATH += $$PWD/../platforms/mac LIBS += -framework Foundation -framework Cocoa } HEADERS += $$PWD/dslider.h\ $$PWD/dthememanager.h \ $$PWD/dapplication.h \ $$PWD/dconstants.h \ $$PWD/dseparatorhorizontal.h \ $$PWD/dseparatorvertical.h \ $$PWD/dbaseline.h \ $$PWD/dheaderline.h \ $$PWD/dbaseexpand.h \ $$PWD/darrowbutton.h \ $$PWD/darrowlineexpand.h \ $$PWD/dswitchlineexpand.h \ $$PWD/dbuttonlist.h \ $$PWD/dimagebutton.h \ $$PWD/dtextbutton.h \ $$PWD/dloadingindicator.h \ $$PWD/dsearchedit.h \ $$PWD/dswitchbutton.h \ $$PWD/dsegmentedcontrol.h \ $$PWD/dlineedit.h \ $$PWD/dcombobox.h \ $$PWD/dcomboboxmodel.h \ $$PWD/dcolorcombobox.h \ $$PWD/dfontcombobox.h \ $$PWD/dsimplecombobox.h \ $$PWD/dwindowmaxbutton.h \ $$PWD/dwindowminbutton.h \ $$PWD/dwindowclosebutton.h \ $$PWD/dwindowrestorebutton.h \ $$PWD/dwindowoptionbutton.h \ $$PWD/dshortcutedit.h \ $$PWD/dsimplelistview.h \ $$PWD/dsimplelistitem.h \ $$PWD/dabstractcomboboxdelegate.h \ $$PWD/dexpandgroup.h \ $$PWD/dlabel.h \ $$PWD/dlinkbutton.h \ $$PWD/dscrollbar.h \ $$PWD/dscrollarea.h \ $$PWD/darrowrectangle.h \ $$PWD/dgraphicsgloweffect.h \ $$PWD/anchors.h \ $$PWD/dbasebutton.h \ $$PWD/dlistwidget.h \ $$PWD/dboxwidget.h \ $$PWD/dcircleprogress.h \ $$PWD/dstackwidget.h \ $$PWD/dfilechooseredit.h \ $$PWD/dpasswordedit.h \ $$PWD/dipv4lineedit.h \ $$PWD/dspinbox.h \ $$PWD/doptionlist.h \ $$PWD/doption.h \ $$PWD/dpicturesequenceview.h \ $$PWD/dflowlayout.h \ $$PWD/dlistview.h \ $$PWD/denhancedwidget.h \ $$PWD/dtextedit.h \ $$PWD/dtitlebar.h \ $$PWD/dwidget.h \ $$PWD/dwindow.h \ $$PWD/dx11widget.h \ $$PWD/dplatformwindowhandle.h \ $$PWD/dmainwindow.h \ $$PWD/dblureffectwidget.h \ $$PWD/dpageindicator.h \ $$PWD/dclipeffectwidget.h \ $$PWD/dgraphicsclipeffect.h \ $$PWD/dvideowidget.h \ $$PWD/dforeignwindow.h \ $$PWD/dpushbutton.h \ $$PWD/dtickeffect.h \ $$PWD/dwaterprogress.h \ $$PWD/dsettingswidgetfactory.h \ $$PWD/dspinner.h \ $$PWD/dcrumbedit.h \ $$PWD/dtabbar.h \ $$PWD/dsuggestbutton.h \ $$PWD/dstyleoption.h \ $$PWD/dtoast.h \ $$PWD/danchors.h SOURCES += $$PWD/dslider.cpp \ $$PWD/dthememanager.cpp \ $$PWD/dapplication.cpp \ $$PWD/dseparatorhorizontal.cpp \ $$PWD/dseparatorvertical.cpp \ $$PWD/dbaseline.cpp \ $$PWD/dheaderline.cpp \ $$PWD/dbaseexpand.cpp \ $$PWD/darrowbutton.cpp \ $$PWD/darrowlineexpand.cpp \ $$PWD/dswitchlineexpand.cpp \ $$PWD/dbuttonlist.cpp \ $$PWD/dimagebutton.cpp \ $$PWD/dtextbutton.cpp \ $$PWD/dloadingindicator.cpp \ $$PWD/dsearchedit.cpp \ $$PWD/dswitchbutton.cpp\ $$PWD/dsegmentedcontrol.cpp \ $$PWD/dlineedit.cpp \ $$PWD/dcombobox.cpp \ $$PWD/dcomboboxmodel.cpp \ $$PWD/dcolorcombobox.cpp \ $$PWD/dfontcombobox.cpp \ $$PWD/dsimplecombobox.cpp\ $$PWD/dwindowmaxbutton.cpp \ $$PWD/dwindowminbutton.cpp \ $$PWD/dwindowclosebutton.cpp \ $$PWD/dwindowrestorebutton.cpp \ $$PWD/dwindowoptionbutton.cpp \ $$PWD/dshortcutedit.cpp \ $$PWD/dsimplelistview.cpp \ $$PWD/dsimplelistitem.cpp \ $$PWD/dabstractcomboboxdelegate.cpp \ $$PWD/dexpandgroup.cpp \ $$PWD/dlabel.cpp \ $$PWD/dlinkbutton.cpp \ $$PWD/dscrollbar.cpp \ $$PWD/dscrollarea.cpp \ $$PWD/darrowrectangle.cpp \ $$PWD/dgraphicsgloweffect.cpp \ $$PWD/anchors.cpp \ $$PWD/dbasebutton.cpp \ $$PWD/dlistwidget.cpp \ $$PWD/dboxwidget.cpp \ $$PWD/dcircleprogress.cpp \ $$PWD/dstackwidget.cpp \ $$PWD/dfilechooseredit.cpp \ $$PWD/dpasswordedit.cpp \ $$PWD/dipv4lineedit.cpp \ $$PWD/dspinbox.cpp \ $$PWD/doptionlist.cpp \ $$PWD/doption.cpp \ $$PWD/dpicturesequenceview.cpp \ $$PWD/dflowlayout.cpp \ $$PWD/dlistview.cpp \ $$PWD/denhancedwidget.cpp \ $$PWD/dtextedit.cpp \ $$PWD/dtitlebar.cpp \ $$PWD/dwindow.cpp \ $$PWD/dwidget.cpp \ $$PWD/dx11widget.cpp \ $$PWD/dplatformwindowhandle.cpp \ $$PWD/dmainwindow.cpp \ $$PWD/dblureffectwidget.cpp \ $$PWD/dpageindicator.cpp \ $$PWD/dclipeffectwidget.cpp \ $$PWD/dgraphicsclipeffect.cpp \ $$PWD/dvideowidget.cpp \ $$PWD/dforeignwindow.cpp \ $$PWD/dpushbutton.cpp \ $$PWD/dtickeffect.cpp \ $$PWD/dwaterprogress.cpp \ $$PWD/dsettingswidgetfactory.cpp \ $$PWD/dspinner.cpp \ $$PWD/dcrumbedit.cpp \ $$PWD/dtabbar.cpp \ $$PWD/dsuggestbutton.cpp \ $$PWD/dstyleoption.cpp \ $$PWD/dtoast.cpp \ $$PWD/danchors.cpp RESOURCES += \ $$PWD/themes/dui_theme_dark.qrc \ $$PWD/themes/dui_theme_light.qrc \ $$PWD/icons.qrc INCLUDEPATH += $$PWD includes.files += $$PWD/*.h includes.files += \ $$PWD/DTitlebar \ $$PWD/DWindow \ $$PWD/DMainWindow \ $$PWD/DAboutDialog \ $$PWD/DApplication \ $$PWD/DBlurEffectWidget \ $$PWD/DClipEffectWidget \ $$PWD/DGraphicsDropShadowEffect \ $$PWD/DPlatformWindowHandle \ $$PWD/DGraphicsClipEffect \ $$PWD/DVideoWidget \ $$PWD/DForeignWindow \ $$PWD/DExpandGroup \ $$PWD/DArrowButton \ $$PWD/DArrowLineExpand \ $$PWD/DThemeManager \ $$PWD/DWaterProgress \ $$PWD/DSimpleListView \ $$PWD/DSimpleListItem \ $$PWD/DSearchEdit \ $$PWD/DPageIndicator \ $$PWD/DSettingsWidgetFactory \ $$PWD/DSettingsDialog \ $$PWD/DSpinner \ $$PWD/DCrumbEdit \ $$PWD/DTabBar \ $$PWD/DSuggestButton \ $$PWD/DStyleOption \ $$PWD/DToast \ $$PWD/DFileDialog dtkwidget-2.0.7.2/tools/000077500000000000000000000000001325435343100150115ustar00rootroot00000000000000dtkwidget-2.0.7.2/tools/svgc/000077500000000000000000000000001325435343100157535ustar00rootroot00000000000000dtkwidget-2.0.7.2/tools/svgc/main.cpp000066400000000000000000000066531325435343100174150ustar00rootroot00000000000000#include #include #include #include #include #include #include "DSvgRenderer" static int String2Int(QString str, int defaultValue) { bool ok = false; auto newValue = str.toInt(&ok); if (!ok || newValue <= 0) { return defaultValue; } return newValue; } static QSize parseSize(QString sizeString, QSize origin = QSize(128, 128)) { if (sizeString.startsWith("x")) { auto newHeight = String2Int(sizeString.remove("x"), origin.height()); auto newWidth = origin.width() * newHeight / origin.height(); return QSize(newWidth, newHeight); } else { auto wh = sizeString.split("x"); wh.removeAll(""); if (1 == wh.length()) { auto newWidth = String2Int(wh.value(0), origin.width()); auto newHeight = origin.height() * newWidth / origin.width(); return QSize(newWidth, newHeight); } if (2 == wh.length()) { auto newWidth = String2Int(wh.value(0), origin.width()); auto newHeight = String2Int(wh.value(1), origin.height()); return QSize(newWidth, newHeight); } } return origin; } int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setOrganizationName("deepin"); app.setApplicationName("dtk-scgc"); QCommandLineParser parser; QCommandLineOption render = QCommandLineOption(QStringList() << "r" << "render", "svg render, DSvgRenderer/QSvgRenderer, default QSvgRenderer", "render", "QSvgRenderer"); QCommandLineOption factor = QCommandLineOption(QStringList() << "f" << "factor", "float scale factor, must > 0, default 1.0", "factor", "1.0"); QCommandLineOption size = QCommandLineOption(QStringList() << "s" << "size", "output size, widthxheight, e.g., 100x200, 100x, x200", "size", "1.0"); parser.addOption(render); parser.addOption(size); parser.addOption(factor); parser.addPositionalArgument("input", "input svg file"); parser.addPositionalArgument("output", "output png file"); parser.addHelpOption(); parser.process(app); auto input = parser.positionalArguments().value(0); auto output = parser.positionalArguments().value(1); if (input.isEmpty() || output.isEmpty()) { parser.showHelp(); } QString renderValue = parser.value("render"); QString sizeValue = parser.value("size"); double factorValue = parser.value("factor").toDouble(); auto inputImage = QImage(input); auto originSize = inputImage.size(); if (originSize.isEmpty()) { originSize = QSize(128, 128); } originSize = parseSize(sizeValue, originSize); auto outputSize = (QSizeF(originSize) * factorValue).toSize(); QImage outPutimage(outputSize, QImage::Format_ARGB32); outPutimage.fill(Qt::transparent); QPainter outputPainter(&outPutimage); if ("DSvgRenderer" == renderValue) { Dtk::Widget::DSvgRenderer renderer(input); renderer.render(&outputPainter); } else { QSvgRenderer renderer(input); renderer.render(&outputPainter); } outPutimage.save(output); return 0; } dtkwidget-2.0.7.2/tools/svgc/svgc.pro000066400000000000000000000024461325435343100174450ustar00rootroot00000000000000QT += gui svg QT += dtkcore TARGET = dtk-svgc CONFIG += c++11 CONFIG -= app_bundle # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 DEFINES += QT_MESSAGELOGCONTEXT isEmpty(PREFIX){ PREFIX = /usr } isEmpty(BIN_INSTALL_DIR) { BIN_INSTALL_DIR=$${PREFIX}/lib/dtk2 } !isEmpty(DTK_STATIC_LIB){ DEFINES += DTK_STATIC_LIB } SOURCES += main.cpp target.path = $${BIN_INSTALL_DIR} INSTALLS += target win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../src/release/ -ldtkwidget else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../src/debug/ -ldtkwidget else:unix: LIBS += -L$$OUT_PWD/../../src/ -ldtkwidget INCLUDEPATH += $$PWD/../../src INCLUDEPATH += $$PWD/../../src/util DEPENDPATH += $$PWD/../../src dtkwidget-2.0.7.2/tools/tools.pro000066400000000000000000000000441325435343100166710ustar00rootroot00000000000000TEMPLATE = subdirs SUBDIRS += svgc dtkwidget-2.0.7.2/tools/translate_generation.py000066400000000000000000000007431325435343100215770ustar00rootroot00000000000000#!env python import sys,os,fnmatch from subprocess import call translations_dir = os.getcwd() + "/translations" if (len(sys.argv) == 2): translations_dir = sys.argv[1] + "/translations" print("set translations dir:", translations_dir) tslist = fnmatch.filter(os.listdir(translations_dir), '*.ts') # This would print all the files and directories for tsfile in tslist: tspath = translations_dir + "/" + tsfile print ("process", tspath) call(["lrelease", tspath]) dtkwidget-2.0.7.2/tools/translate_generation.sh000077500000000000000000000003501325435343100215560ustar00rootroot00000000000000#!/bin/bash # this file is used to auto-generate .qm file from .ts file. # author: shibowen at linuxdeepin.com ts_list=(`ls translations/*.ts`) for ts in "${ts_list[@]}" do printf "\nprocess ${ts}\n" lrelease "${ts}" done dtkwidget-2.0.7.2/translations/000077500000000000000000000000001325435343100163725ustar00rootroot00000000000000dtkwidget-2.0.7.2/translations/dtkwidget2.ts000066400000000000000000000140631325435343100210160ustar00rootroot00000000000000 DAboutDialog Acknowledgements Version: %1 %1 is released under %2 DCrumbEdit Black White Dark Gray Gray Light Gray Red Green Blue Cyan Magenta Yellow Dark Red Dark Green Dark Blue Dark Cyan Dark Magenta Dark Yellow DInputDialog Cancel Confirm DShortcutEdit Please input a new shortcut None QObject No search result Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help About Exit dtkwidget-2.0.7.2/translations/dtkwidget2_am_ET.ts000066400000000000000000000061161325435343100220630ustar00rootroot00000000000000 DAboutDialog Acknowledgements ምስጋና ለ ተርጓሚው ሳምሶን በለጠ በላይነህ Version: %1 እትም: %1 %1 is released under %2 %1 የ ተለቀቀው በዚህ መሰረት ነው %2 DInputDialog Cancel መሰረዣ Confirm ማረጋገጫ DShortcutEdit Please input a new shortcut እባክዎን አዲስ አቋራጭ ያስገቡ None ምንም DSimpleListView No search result ምንም ውጤት አልተገኘም QObject Restore Defaults ነባር እንደ ነበር መመለሻ ShortcutEdit Please enter a new shortcut እባክዎን አዲስ አቋራጭ ያስገቡ TitleBarMenu Help እርዳታ About ስለ Exit መውጫ dtkwidget-2.0.7.2/translations/dtkwidget2_ar.ts000066400000000000000000000057631325435343100215070ustar00rootroot00000000000000 DAboutDialog Acknowledgements شكر وتقدير Version: %1 إصدار: 1% %1 is released under %2 %1 أطلق بموجب 2% DInputDialog Cancel إلغاء Confirm تأكيد DShortcutEdit Please input a new shortcut الرجاء إدخال اختصاراّ جديداً None غير موجود DSimpleListView No search result لا توجد نتائج بحث QObject Restore Defaults استعادة الاعدادت الإفتراضية ShortcutEdit Please enter a new shortcut يرجى إدراج مختصر جديد TitleBarMenu Help مساعدة About حول Exit خروج dtkwidget-2.0.7.2/translations/dtkwidget2_ast.ts000066400000000000000000000055021325435343100216630ustar00rootroot00000000000000 DAboutDialog Acknowledgements Agradecimientos Version: %1 %1 is released under %2 DInputDialog Cancel Encaboxar Confirm Confirmar DShortcutEdit Please input a new shortcut Introduz un atayu nuevu, por favor None Dengún DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help Ayuda About Tocante a Exit Colar dtkwidget-2.0.7.2/translations/dtkwidget2_bg.ts000066400000000000000000000060521325435343100214650ustar00rootroot00000000000000 DAboutDialog Acknowledgements Благодарности Version: %1 Версия: %1 %1 is released under %2 %1 е реализиран под %2 DInputDialog Cancel Отказ Confirm Потвърждавам DShortcutEdit Please input a new shortcut Моля въведете нов пряк път None Нищо DSimpleListView No search result Търсенето е без резултат QObject Restore Defaults Възстановяване на настройките ShortcutEdit Please enter a new shortcut Моля въведете нов пряк път TitleBarMenu Help Помощ About Относно Exit Изход dtkwidget-2.0.7.2/translations/dtkwidget2_ca.ts000066400000000000000000000056711325435343100214660ustar00rootroot00000000000000 DAboutDialog Acknowledgements Agraïments Version: %1 Versió: %1 %1 is released under %2 %1 està publicada d'acord amb %2 DInputDialog Cancel Cancel·la Confirm Confirmeu-ho DShortcutEdit Please input a new shortcut Si us plau, introduïu una drecera nova. None Cap DSimpleListView No search result Cap resultat de la cerca QObject Restore Defaults Restableix els valors per defecte ShortcutEdit Please enter a new shortcut Si us plau, introduïu una drecera nova: TitleBarMenu Help Ajuda About Quant a Exit Surt dtkwidget-2.0.7.2/translations/dtkwidget2_cs.ts000066400000000000000000000056221325435343100215040ustar00rootroot00000000000000 DAboutDialog Acknowledgements Poděkování Version: %1 Verze: %1 %1 is released under %2 %1 je vydán pod %2 DInputDialog Cancel Zrušit Confirm Potvrdit DShortcutEdit Please input a new shortcut Zadejte, prosím, novou zkratku None Žádný DSimpleListView No search result Žádný výsledek hledání QObject Restore Defaults Obnovit výchozí ShortcutEdit Please enter a new shortcut Zadejte, prosím, novou zkratku TitleBarMenu Help Nápověda About O programu Exit Ukončit dtkwidget-2.0.7.2/translations/dtkwidget2_da.ts000066400000000000000000000055731325435343100214700ustar00rootroot00000000000000 DAboutDialog Acknowledgements Tilkendegivelser Version: %1 Version: %1 %1 is released under %2 %1 er udgivet under %2 DInputDialog Cancel Annuller Confirm Bekræft DShortcutEdit Please input a new shortcut Input venligst en ny genvej None Ingen DSimpleListView No search result Intet søgeresultat QObject Restore Defaults Gendan standarder ShortcutEdit Please enter a new shortcut Indtast venligst en ny genvej TitleBarMenu Help Hjælp About Om Exit Afslut dtkwidget-2.0.7.2/translations/dtkwidget2_de.ts000066400000000000000000000056641325435343100214750ustar00rootroot00000000000000 DAboutDialog Acknowledgements Anerkennungen Version: %1 Version: %1 %1 is released under %2 %1 wurde unter %2 veröffentlicht. DInputDialog Cancel Abbrechen Confirm Bestätigen DShortcutEdit Please input a new shortcut Bitte geben Sie ein neues Tastenkürzel ein None Keine DSimpleListView No search result Kein Suchergebnis QObject Restore Defaults Standardwerte wiederherstellen ShortcutEdit Please enter a new shortcut Bitte geben Sie ein neues Tastenkürzel ein TitleBarMenu Help Hilfe About Über Exit Beenden dtkwidget-2.0.7.2/translations/dtkwidget2_el.ts000066400000000000000000000056121325435343100214760ustar00rootroot00000000000000 DAboutDialog Acknowledgements αναγνωρισμοί Version: %1 %1 is released under %2 DInputDialog Cancel Ακύρωση Confirm Επικύρωση DShortcutEdit Please input a new shortcut Παρακαλώ εισάγετε ένα νέο σύνδεσμο None Κανένα DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help Βοήθεια About Περί Exit Έξοδος dtkwidget-2.0.7.2/translations/dtkwidget2_es.ts000066400000000000000000000136321325435343100215060ustar00rootroot00000000000000 DAboutDialog Acknowledgements Agradecimientos Version: %1 Versión %1 %1 is released under %2 %1 está lanzado bajo %2 DCrumbEdit Black Negro White Blanco Dark Gray Gris oscuro Gray Gris Light Gray Gris claro Red Rojo Green Verde Blue Azul Cyan Cian Magenta Magenta Yellow Amarillo Dark Red Rojo oscuro Dark Green Verde oscuro Dark Blue Azul oscuro Dark Cyan Cian oscuro Dark Magenta Magenta oscuro Dark Yellow Amarillo oscuro DInputDialog Cancel Cancelar Confirm Confirmar DShortcutEdit Please input a new shortcut Introduzca un nuevo atajo None Nada DSimpleListView No search result Sin resultado de búsqueda QObject Restore Defaults Restaurar valores predeterminados ShortcutEdit Please enter a new shortcut Ingrese un nuevo atajo TitleBarMenu Help Ayuda About Acerca de Exit Salir dtkwidget-2.0.7.2/translations/dtkwidget2_es_419.ts000066400000000000000000000056231325435343100221040ustar00rootroot00000000000000 DAboutDialog Acknowledgements Agradecimientos Version: %1 Versión %1 %1 is released under %2 %1 está lanzado bajo %2 DInputDialog Cancel Cancelar Confirm Confirmar DShortcutEdit Please input a new shortcut Introduzca un nuevo atajo None Nada DSimpleListView No search result Sin resultado de búsqueda QObject Restore Defaults Restaurar valores predeterminados ShortcutEdit Please enter a new shortcut Ingrese un nuevo atajo TitleBarMenu Help Ayuda About Acerca de Exit Salir dtkwidget-2.0.7.2/translations/dtkwidget2_fr.ts000066400000000000000000000056111325435343100215040ustar00rootroot00000000000000 DAboutDialog Acknowledgements Remerciements Version: %1 Version : %1 %1 is released under %2 %1 est publié sous %2 DInputDialog Cancel Annuler Confirm Confirmer DShortcutEdit Please input a new shortcut Veuillez entrer un nouveau raccourci None Aucun DSimpleListView No search result Aucun résultat QObject Restore Defaults Réinitialiser ShortcutEdit Please enter a new shortcut Veuillez entrer un nouveau raccourci TitleBarMenu Help Aide About À propos Exit Sortir dtkwidget-2.0.7.2/translations/dtkwidget2_gl_ES.ts000066400000000000000000000054761325435343100220770ustar00rootroot00000000000000 DAboutDialog Acknowledgements Recoñecementos Version: %1 %1 is released under %2 DInputDialog Cancel Cancelar Confirm Confirmar DShortcutEdit Please input a new shortcut Por favor, inserte un novo atallo None Ningún DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help Axuda About Sobre Exit Saír dtkwidget-2.0.7.2/translations/dtkwidget2_he.ts000066400000000000000000000055401325435343100214720ustar00rootroot00000000000000 DAboutDialog Acknowledgements הוקרת תודה Version: %1 %1 is released under %2 DInputDialog Cancel ביטול Confirm אישור DShortcutEdit Please input a new shortcut נא להקליד צירוף מקשים חדש None ללא DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help עזרה About על אודות Exit יציאה dtkwidget-2.0.7.2/translations/dtkwidget2_hr.ts000066400000000000000000000054751325435343100215160ustar00rootroot00000000000000 DAboutDialog Acknowledgements Priznanja Version: %1 %1 is released under %2 DInputDialog Cancel Odustani Confirm Potvrdi DShortcutEdit Please input a new shortcut Molimo Vas da unesete novi prečac None Niti jedan DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help Pomoć About O programu Exit Izlaz dtkwidget-2.0.7.2/translations/dtkwidget2_hu.ts000066400000000000000000000057111325435343100215120ustar00rootroot00000000000000 DAboutDialog Acknowledgements Köszönetnyilvánítás Version: %1 %1 verzió %1 is released under %2 A %1 a %2 alatti kiadás DInputDialog Cancel Mégsem Confirm Megerősítés DShortcutEdit Please input a new shortcut Kérjük, adjon meg egy új parancsikont None Egyik sem DSimpleListView No search result Nincs keresési eredmény QObject Restore Defaults Visszaállítás alaphelyzetbe ShortcutEdit Please enter a new shortcut Hozzon létre egy új parancsikont TitleBarMenu Help Segítség About Az alkalmazásról Exit Kilépés dtkwidget-2.0.7.2/translations/dtkwidget2_id.ts000066400000000000000000000055001325435343100214660ustar00rootroot00000000000000 DAboutDialog Acknowledgements Ucapan terima kasih Version: %1 %1 is released under %2 DInputDialog Cancel Batal Confirm Konfirmasi DShortcutEdit Please input a new shortcut Silakan masukan pintasan baru None Tidak ada DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help Bantuan About Tentang Exit Keluar dtkwidget-2.0.7.2/translations/dtkwidget2_it.ts000066400000000000000000000056261325435343100215170ustar00rootroot00000000000000 DAboutDialog Acknowledgements Ringraziamenti Version: %1 Versione: %1 %1 is released under %2 %1 è rilasciato secondo %2 DInputDialog Cancel Cancella Confirm Conferma DShortcutEdit Please input a new shortcut Inserisci una nuova scorciatoia None No DSimpleListView No search result Nessun risultato disponibile QObject Restore Defaults Ripristina valori predefiniti ShortcutEdit Please enter a new shortcut Inserisci una nuova scorciatoia TitleBarMenu Help Aiuto About Info Exit Esci dtkwidget-2.0.7.2/translations/dtkwidget2_ja.ts000066400000000000000000000055231325435343100214710ustar00rootroot00000000000000 DAboutDialog Acknowledgements 謝辞 Version: %1 %1 is released under %2 DInputDialog Cancel 取り消す Confirm 確認 DShortcutEdit Please input a new shortcut 新しいショートカットを入力して下さい None なし DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help ヘルプ About について Exit 終了 dtkwidget-2.0.7.2/translations/dtkwidget2_lt.ts000066400000000000000000000056071325435343100215210ustar00rootroot00000000000000 DAboutDialog Acknowledgements Padėkos Version: %1 Versija: %1 %1 is released under %2 %1 yra išleista pagal %2 DInputDialog Cancel Atsisakyti Confirm Patvirtinti DShortcutEdit Please input a new shortcut Įveskite naują trumpinį None Nėra DSimpleListView No search result Nėra paieškos rezultatų QObject Restore Defaults Atkurti numatytuosius ShortcutEdit Please enter a new shortcut Įveskite naują trumpinį TitleBarMenu Help Žinynas About Apie Exit Išeiti dtkwidget-2.0.7.2/translations/dtkwidget2_ms.ts000066400000000000000000000056011325435343100215130ustar00rootroot00000000000000 DAboutDialog Acknowledgements Penghargaan Version: %1 Versi: %1 %1 is released under %2 %1 dikeluarkan bawah %2 DInputDialog Cancel Batal Confirm Sahkan DShortcutEdit Please input a new shortcut Sila masukkan satu pintasan baharu None Tiada DSimpleListView No search result Tiada keputusan gelintar QObject Restore Defaults Pulih Lalai ShortcutEdit Please enter a new shortcut Sila masukkan satu pintasan baharu TitleBarMenu Help Bantuan About Perihal Exit Keluar dtkwidget-2.0.7.2/translations/dtkwidget2_nl.ts000066400000000000000000000054721325435343100215130ustar00rootroot00000000000000 DAboutDialog Acknowledgements Erkenningen Version: %1 %1 is released under %2 DInputDialog Cancel Annuleren Confirm Bevestigen DShortcutEdit Please input a new shortcut Voer a.u.b. een nieuwe sneltoets in None Geen DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help Help About Over Exit Afsluiten dtkwidget-2.0.7.2/translations/dtkwidget2_pl.ts000066400000000000000000000056321325435343100215130ustar00rootroot00000000000000 DAboutDialog Acknowledgements Podziękowania Version: %1 Wersja: %1 %1 is released under %2 %1 zostało wydane w oparciu o %2 DInputDialog Cancel Anuluj Confirm Potwierdź DShortcutEdit Please input a new shortcut Prosimy wprowadzić nowy skrót None Brak DSimpleListView No search result Brak wyników wyszukiwania QObject Restore Defaults Przywróć domyślne ShortcutEdit Please enter a new shortcut Prosimy wprowadzić nowy skrót TitleBarMenu Help Pomoc About O programie Exit Wyjdź dtkwidget-2.0.7.2/translations/dtkwidget2_pt.ts000066400000000000000000000056051325435343100215230ustar00rootroot00000000000000 DAboutDialog Acknowledgements Agradecimentos Version: %1 Versão: %1 %1 is released under %2 %1 é publicada sobre %2 DInputDialog Cancel Cancelar Confirm Confirmar DShortcutEdit Please input a new shortcut Por favor crie um novo atalho None Nenhum DSimpleListView No search result Pesquisa sem resultados QObject Restore Defaults Restaurar originais ShortcutEdit Please enter a new shortcut Por favor crie um novo atalho TitleBarMenu Help Ajuda About Sobre Exit Sair dtkwidget-2.0.7.2/translations/dtkwidget2_pt_BR.ts000066400000000000000000000056061325435343100221070ustar00rootroot00000000000000 DAboutDialog Acknowledgements Agradecimentos Version: %1 Versão: %1 %1 is released under %2 %1 é lançado em %2 DInputDialog Cancel Cancelar Confirm Confirmar DShortcutEdit Please input a new shortcut Por favor, insira um novo atalho None Nenhum DSimpleListView No search result Nenhum resultado de pesquisa QObject Restore Defaults Restauração padrão ShortcutEdit Please enter a new shortcut Digite um novo atalho TitleBarMenu Help Ajuda About Sobre Exit Sair dtkwidget-2.0.7.2/translations/dtkwidget2_ru.ts000066400000000000000000000061431325435343100215240ustar00rootroot00000000000000 DAboutDialog Acknowledgements Выражение признательности Version: %1 Версия: %1 %1 is released under %2 %1 выпущен под %2 DInputDialog Cancel Отмена Confirm Подтвердить DShortcutEdit Please input a new shortcut Пожалуйста введите новое сочетание None Ничего DSimpleListView No search result Ничего не найдено QObject Restore Defaults Восстановить значения По-умолчанию ShortcutEdit Please enter a new shortcut Пожалуйста введите новое сочетание TitleBarMenu Help Помощь About О программе Exit Выход dtkwidget-2.0.7.2/translations/dtkwidget2_sk.ts000066400000000000000000000056121325435343100215130ustar00rootroot00000000000000 DAboutDialog Acknowledgements Poďakovanie Version: %1 Verzia: %1 %1 is released under %2 %1 je vydaná pod %2 DInputDialog Cancel Zrušiť Confirm Potvrdiť DShortcutEdit Please input a new shortcut Prosím zadajte novú skratku None Nič DSimpleListView No search result Žiadny výsledok vyhľadávania QObject Restore Defaults Obnoviť predvolené nastavenia ShortcutEdit Please enter a new shortcut Zadajte novú skratku TitleBarMenu Help Pomoc About O Exit Ukončiť dtkwidget-2.0.7.2/translations/dtkwidget2_sl.ts000066400000000000000000000055701325435343100215170ustar00rootroot00000000000000 DAboutDialog Acknowledgements Zasluge Version: %1 Različica: %1 %1 is released under %2 %1 je izdana pod %2 DInputDialog Cancel Prekliči Confirm Potrdi DShortcutEdit Please input a new shortcut Prosim, vnesite novo bližnjico None Nič DSimpleListView No search result Ni rezultatov iskanja QObject Restore Defaults Obnovi privzeto ShortcutEdit Please enter a new shortcut Prosim, vnesite novo bližnjico TitleBarMenu Help Pomoč About O tem Exit Izhod dtkwidget-2.0.7.2/translations/dtkwidget2_sr.ts000066400000000000000000000054211325435343100215200ustar00rootroot00000000000000 DAboutDialog Acknowledgements Version: %1 %1 is released under %2 DInputDialog Cancel Confirm DShortcutEdit Please input a new shortcut None DSimpleListView No search result QObject Restore Defaults ShortcutEdit Please enter a new shortcut TitleBarMenu Help Помоћ About Exit dtkwidget-2.0.7.2/translations/dtkwidget2_tr.ts000066400000000000000000000056321325435343100215250ustar00rootroot00000000000000 DAboutDialog Acknowledgements Teşekkürler Version: %1 Sürüm: %1 %1 is released under %2 %2 altında %1 yayınlandı DInputDialog Cancel İptal Et Confirm Doğrula DShortcutEdit Please input a new shortcut Lütfen yeni bir kısayol giriniz None Hiçbiri DSimpleListView No search result Arama sonucu yok QObject Restore Defaults Varsayılanları Geri Yükle ShortcutEdit Please enter a new shortcut Lütfen yeni bir kısayol giriniz TitleBarMenu Help Yardım About Hakkında Exit Çık dtkwidget-2.0.7.2/translations/dtkwidget2_uk.ts000066400000000000000000000062011325435343100215100ustar00rootroot00000000000000 DAboutDialog Acknowledgements Подяки Version: %1 Версія: %1 %1 is released under %2 %1 випущено за умов дотримання %2 DInputDialog Cancel Скасувати Confirm Підтвердити DShortcutEdit Please input a new shortcut Будь ласка, вкажіть нове клавіатурне скорочення None Немає DSimpleListView No search result Немає результату пошуку QObject Restore Defaults Відновити значення за замовчуванням ShortcutEdit Please enter a new shortcut Будь ласка, введіть новий ярлик TitleBarMenu Help Довідка About Про програму Exit Вийти dtkwidget-2.0.7.2/translations/dtkwidget2_zh_CN.ts000066400000000000000000000140051325435343100220730ustar00rootroot00000000000000 DAboutDialog Acknowledgements 鸣谢 Version: %1 版本:%1 %1 is released under %2 %1遵循%2协议发布 DCrumbEdit Black 黑色 White 白色 Dark Gray 深灰色 Gray 灰色 Light Gray 浅灰色 Red 红色 Green 绿色 Blue 蓝色 Cyan 青色 Magenta 洋红色 Yellow 黄色 Dark Red 深红色 Dark Green 深绿色 Dark Blue 深蓝色 Dark Cyan 深青色 Dark Magenta 深紫红色 Dark Yellow 深黄色 DInputDialog Cancel 取消 Confirm 确定 DShortcutEdit Please input a new shortcut 请输入新的快捷键 None DSimpleListView No search result 无搜索结果 QObject Restore Defaults 恢复默认设置 No search result 无搜索结果 ShortcutEdit Please enter a new shortcut 请输入新的快捷键 TitleBarMenu Help 帮助 About 关于 Exit 退出 dtkwidget-2.0.7.2/translations/dtkwidget2_zh_TW.ts000066400000000000000000000055321325435343100221320ustar00rootroot00000000000000 DAboutDialog Acknowledgements 鳴謝 Version: %1 版本:%1 %1 is released under %2 %1遵循 %2 發布 DInputDialog Cancel 取消 Confirm 確定 DShortcutEdit Please input a new shortcut 請輸入新快速鍵 None DSimpleListView No search result 找不到結果 QObject Restore Defaults 還原預設值 ShortcutEdit Please enter a new shortcut 請輸入新快速鍵 TitleBarMenu Help 說明 About 關於 Exit 離開