Changeset View
Changeset View
Standalone View
Standalone View
krusader/Dialogs/krspecialwidgets.cpp
Context not available. | |||||
61 | freeSpace(_free), alias(std::move(_alias)), realName(std::move(_realName)), mounted(true), | 61 | freeSpace(_free), alias(std::move(_alias)), realName(std::move(_realName)), mounted(true), | ||
---|---|---|---|---|---|
62 | empty(false), supermount(false) | 62 | empty(false), supermount(false) | ||
63 | { | 63 | { | ||
64 | 64 | const QMargins margins = contentsMargins(); | |||
65 | int leftMargin, topMargin, rightMargin, bottomMargin; | 65 | resize(150 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom()); | ||
66 | getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); | 66 | setMinimumSize(150 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom()); | ||
67 | resize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin); | | |||
68 | setMinimumSize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin); | | |||
69 | show(); | 67 | show(); | ||
70 | } | 68 | } | ||
71 | 69 | | |||
Context not available. | |||||
74 | QWidget(parent), alias(std::move(_alias)), realName(std::move(_realName)), mounted(false), | 72 | QWidget(parent), alias(std::move(_alias)), realName(std::move(_realName)), mounted(false), | ||
75 | empty(false), supermount(sm) | 73 | empty(false), supermount(sm) | ||
76 | { | 74 | { | ||
77 | 75 | const QMargins margins = contentsMargins(); | |||
78 | int leftMargin, topMargin, rightMargin, bottomMargin; | 76 | resize(150 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom()); | ||
79 | getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); | 77 | setMinimumSize(150 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom()); | ||
80 | resize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin); | | |||
81 | setMinimumSize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin); | | |||
82 | show(); | 78 | show(); | ||
83 | } | 79 | } | ||
84 | 80 | | |||
Context not available. | |||||
86 | // when filesystem statistics haven't been calculated yet) | 82 | // when filesystem statistics haven't been calculated yet) | ||
87 | KRFSDisplay::KRFSDisplay(QWidget *parent) : QWidget(parent), empty(true) | 83 | KRFSDisplay::KRFSDisplay(QWidget *parent) : QWidget(parent), empty(true) | ||
88 | { | 84 | { | ||
89 | 85 | const QMargins margins = contentsMargins(); | |||
90 | int leftMargin, topMargin, rightMargin, bottomMargin; | 86 | resize(150 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom()); | ||
91 | getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); | 87 | setMinimumSize(150 + margins.left() + margins.right(), 200 + margins.top() + margins.bottom()); | ||
92 | resize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin); | | |||
93 | setMinimumSize(150 + leftMargin + rightMargin, 200 + topMargin + bottomMargin); | | |||
94 | show(); | 88 | show(); | ||
95 | } | 89 | } | ||
96 | 90 | | |||
Context not available. | |||||
100 | { | 94 | { | ||
101 | QPainter paint(this); | 95 | QPainter paint(this); | ||
102 | if (!empty) { | 96 | if (!empty) { | ||
103 | int leftMargin, topMargin, rightMargin, bottomMargin; | 97 | const QMargins margins = contentsMargins(); | ||
104 | getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); | | |||
105 | // create the text | 98 | // create the text | ||
106 | // first, name and location | 99 | // first, name and location | ||
107 | QFont font = paint.font(); | 100 | QFont font = paint.font(); | ||
108 | font.setWeight(QFont::Bold); | 101 | font.setWeight(QFont::Bold); | ||
109 | paint.setFont(font); | 102 | paint.setFont(font); | ||
110 | paint.drawText(leftMargin + 10, topMargin + 20, alias); | 103 | paint.drawText(margins.left() + 10, margins.top() + 20, alias); | ||
111 | 104 | | |||
112 | font.setWeight(QFont::Normal); | 105 | font.setWeight(QFont::Normal); | ||
113 | paint.setFont(font); | 106 | paint.setFont(font); | ||
114 | paint.drawText(leftMargin + 10, topMargin + 37, '(' + realName + ')'); | 107 | paint.drawText(margins.left() + 10, margins.top() + 37, '(' + realName + ')'); | ||
115 | 108 | | |||
116 | if (mounted) { // incase the filesystem is already mounted | 109 | if (mounted) { // incase the filesystem is already mounted | ||
117 | // second, the capacity | 110 | // second, the capacity | ||
118 | paint.drawText(leftMargin + 10, topMargin + 70, i18n("Capacity: %1", KIO::convertSizeFromKiB(totalSpace))); | 111 | paint.drawText(margins.left() + 10, margins.top() + 70, i18n("Capacity: %1", KIO::convertSizeFromKiB(totalSpace))); | ||
119 | // third, the 2 boxes (used, free) | 112 | // third, the 2 boxes (used, free) | ||
120 | QPen systemPen = paint.pen(); | 113 | QPen systemPen = paint.pen(); | ||
121 | paint.setPen(Qt::black); | 114 | paint.setPen(Qt::black); | ||
122 | paint.drawRect(leftMargin + 10, topMargin + 90, 10, 10); | 115 | paint.drawRect(margins.left() + 10, margins.top() + 90, 10, 10); | ||
123 | paint.fillRect(leftMargin + 11, topMargin + 91, 8, 8, QBrush(Qt::gray)); | 116 | paint.fillRect(margins.left() + 11, margins.top() + 91, 8, 8, QBrush(Qt::gray)); | ||
124 | paint.drawRect(leftMargin + 10, topMargin + 110, 10, 10); | 117 | paint.drawRect(margins.left() + 10, margins.top() + 110, 10, 10); | ||
125 | paint.fillRect(leftMargin + 11, topMargin + 111, 8, 8, QBrush(Qt::white)); | 118 | paint.fillRect(margins.left() + 11, margins.top() + 111, 8, 8, QBrush(Qt::white)); | ||
126 | // now, the text for the boxes | 119 | // now, the text for the boxes | ||
127 | paint.setPen(systemPen); | 120 | paint.setPen(systemPen); | ||
128 | paint.drawText(leftMargin + 25, topMargin + 100, i18n("Used: %1", KIO::convertSizeFromKiB(totalSpace - freeSpace))); | 121 | paint.drawText(margins.left() + 25, margins.top() + 100, i18n("Used: %1", KIO::convertSizeFromKiB(totalSpace - freeSpace))); | ||
129 | paint.drawText(leftMargin + 25, topMargin + 120, i18n("Free: %1", KIO::convertSizeFromKiB(freeSpace))); | 122 | paint.drawText(margins.left() + 25, margins.top() + 120, i18n("Free: %1", KIO::convertSizeFromKiB(freeSpace))); | ||
130 | // first, create the empty pie | 123 | // first, create the empty pie | ||
131 | // bottom... | 124 | // bottom... | ||
132 | paint.setPen(Qt::black); | 125 | paint.setPen(Qt::black); | ||
133 | paint.setBrush(Qt::white); | 126 | paint.setBrush(Qt::white); | ||
134 | paint.drawPie(leftMargin + LEFT, topMargin + BOTTOM, WIDTH, HEIGHT, STARTANGLE, DEG(360)); | 127 | paint.drawPie(margins.left() + LEFT, margins.top() + BOTTOM, WIDTH, HEIGHT, STARTANGLE, DEG(360)); | ||
135 | // body... | 128 | // body... | ||
136 | paint.setPen(Qt::lightGray); | 129 | paint.setPen(Qt::lightGray); | ||
137 | for (int i = 1; i < Z_HEIGHT; ++i) | 130 | for (int i = 1; i < Z_HEIGHT; ++i) | ||
138 | paint.drawPie(leftMargin + LEFT, topMargin + BOTTOM - i, WIDTH, HEIGHT, STARTANGLE, DEG(360)); | 131 | paint.drawPie(margins.left() + LEFT, margins.top() + BOTTOM - i, WIDTH, HEIGHT, STARTANGLE, DEG(360)); | ||
139 | // side lines... | 132 | // side lines... | ||
140 | paint.setPen(Qt::black); | 133 | paint.setPen(Qt::black); | ||
141 | paint.drawLine(leftMargin + LEFT, topMargin + BOTTOM + HEIGHT / 2, LEFT, BOTTOM + HEIGHT / 2 - Z_HEIGHT); | 134 | paint.drawLine(margins.left() + LEFT, margins.top() + BOTTOM + HEIGHT / 2, LEFT, BOTTOM + HEIGHT / 2 - Z_HEIGHT); | ||
142 | paint.drawLine(leftMargin + LEFT + WIDTH, topMargin + BOTTOM + HEIGHT / 2, LEFT + WIDTH, BOTTOM + HEIGHT / 2 - Z_HEIGHT); | 135 | paint.drawLine(margins.left() + LEFT + WIDTH, margins.top() + BOTTOM + HEIGHT / 2, LEFT + WIDTH, BOTTOM + HEIGHT / 2 - Z_HEIGHT); | ||
143 | // top of the pie | 136 | // top of the pie | ||
144 | paint.drawPie(leftMargin + LEFT, topMargin + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, DEG(360)); | 137 | paint.drawPie(margins.left() + LEFT, margins.top() + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, DEG(360)); | ||
145 | // the "used space" slice | 138 | // the "used space" slice | ||
146 | float i = ((float)(totalSpace - freeSpace) / (totalSpace)) * 360.0; | 139 | float i = ((float)(totalSpace - freeSpace) / (totalSpace)) * 360.0; | ||
147 | paint.setBrush(Qt::gray); | 140 | paint.setBrush(Qt::gray); | ||
148 | paint.drawPie(leftMargin + LEFT, topMargin + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, (int) DEG(i)); | 141 | paint.drawPie(margins.left() + LEFT, margins.top() + BOTTOM - Z_HEIGHT, WIDTH, HEIGHT, STARTANGLE, (int) DEG(i)); | ||
149 | // if we need to draw a 3d stripe ... | 142 | // if we need to draw a 3d stripe ... | ||
150 | if (i > 180.0) { | 143 | if (i > 180.0) { | ||
151 | for (int j = 1; j < Z_HEIGHT; ++j) | 144 | for (int j = 1; j < Z_HEIGHT; ++j) | ||
152 | paint.drawArc(leftMargin + LEFT, topMargin + BOTTOM - j, WIDTH, HEIGHT, STARTANGLE - 16 * 180, (int)(DEG(i - 180.0))); | 145 | paint.drawArc(margins.left() + LEFT, margins.top() + BOTTOM - j, WIDTH, HEIGHT, STARTANGLE - 16 * 180, (int)(DEG(i - 180.0))); | ||
153 | } | 146 | } | ||
154 | } else { // if the filesystem is unmounted... | 147 | } else { // if the filesystem is unmounted... | ||
155 | font.setWeight(QFont::Bold); | 148 | font.setWeight(QFont::Bold); | ||
156 | paint.setFont(font); | 149 | paint.setFont(font); | ||
157 | paint.drawText(leftMargin + 10, topMargin + 60, i18n("Not mounted.")); | 150 | paint.drawText(margins.left() + 10, margins.top() + 60, i18n("Not mounted.")); | ||
158 | } | 151 | } | ||
159 | } else { // if the widget is in empty situation... | 152 | } else { // if the widget is in empty situation... | ||
160 | 153 | | |||
Context not available. |